This question already has an answer here:
How would i overload the operator that is used in a for loop
i would like to be able to get my std::vector from myclass
but also be able to use ::Get() to still return the class
template<typename T>
class Singleton
{
protected:
Singleton() {}
~Singleton() {}
Singleton(const Singleton&) = delete;
Singleton& operator=(const Singleton&) = delete;
Singleton(Singleton&&) = delete;
Singleton& operator=(Singleton&&) = delete;
public:
static inline T& Get()
{
static T inst{};
return inst;
}
};
class Random : public Singleton<Random>
{
public:
std::vector<int> ALL() { return _vec; }
private:
std::vector<int> _vec;
};
for (auto c : Random::Get()) //<----- how would i make this work to get the std::vector
{
}
Aucun commentaire:
Enregistrer un commentaire