1

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<class Test> WP_Test;
vector<WP_Testl> TestVector;

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

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

Mat
  • 202,337
  • 40
  • 393
  • 406

0 Answers0