jeudi 29 décembre 2016

Placing reference to object on global list or vector

I am looking for a way to place a reference to an object on a global list or vector. I think I need something like weak_from_this() in c++17. Unfortunately I need to use c++11:( I would like to do something like:

typedef std::weak_ptr WP_Test; vector TestVector;

class Test { ... void placeOnVector() { TestVector.push_back(this);} }

But the compiler is unable to convert "this" to a weak_ptr.

Aucun commentaire:

Enregistrer un commentaire