0

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?

skaffman
  • 398,947
  • 96
  • 818
  • 769
nickolay
  • 3,643
  • 3
  • 32
  • 40

1 Answers1

0

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.

Community
  • 1
  • 1
nickolay
  • 3,643
  • 3
  • 32
  • 40