We know that shared ownership has two underlying strategies:
- non-intrusive and
- intrusive
Please help me to understand what do these strategies mean? What are implementation details?
We know that shared ownership has two underlying strategies:
Please help me to understand what do these strategies mean? What are implementation details?
Non-intrusive is when the smart pointer object provides reference counting.
Ex.: std::shared_ptr
, boost::shared_ptr
Intrusive is when the smart pointer relies on stored object embedded reference counting (i.e. stored object is responsible for reference counting).
Ex.: boost::intrusive_ptr
Note: intrusive pointer needs the "glue" code to increment and decrement reference counter inside the stored object. In boost library you must provide 2 functions to the intrusive_ptr
object to perform reference counter increment and decrement.
smart pointers (boost) explained There is no direct answer on my question here but is very helpful as a quick overview of smart pointers semantics.