Marc Andreson
Marc Andreson

Reputation: 3495

intrusive pointers from this

How can a this pointer be passed to a method that expects intrusive_ptr (such as the one from boost)? For shared_ptrs there is enable_shared_from_this.

Upvotes: 0

Views: 273

Answers (1)

Zan Lynx
Zan Lynx

Reputation: 54345

When using intrusive_ptr the class itself is responsible for handling its reference counts. So passing a pointer to itself is easy!

All it has to do is increment its own reference counter and pass this. Done.

Upvotes: 2

Related Questions