Quick Q: How do I cast 'this' to std::shared_ptr? -- StackOverflow

Quick A: Inherit from enable_shared_from_this.

Recently on SO:

Cast 'this' to std::shared_ptr

I have a method on a class to make a particular instance an "active" instance:

void makeActive() { activeInstance = this; }

However it doesn't work since activeInstance has type std::shared_ptr< ClassName >. How can I cast this to std::shared_ptr<ClassName>?

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.