Rosetta 3.4
|
owning_ptr is designed to be a shared-ownership intrusive reference counted smart pointer much like boost::intrusive_ptr but with a few modifications.
Differences from intrusive_ptr:
Ownership of the pointee object can be shared with intrusive_ptr or other smart pointers that use the same reference counting mechanism in the object.
Pointers to const objects: owning_ptr< Type const >
Virtual functions shouldn't return owning_ptr because, like all template-based smart pointers, it doesn't support covariant return types but raw pointer return values can be assigned to owning_ptr.
Casts: The cast functions are merely a convenience for owning_ptr (unlike for non-intrusive shared ownership pointers) so for:
owning_ptr< Base > pB( new Derived() );
the cast:
dynamic_pointer_cast< Derived >( pB );
is equivalent to:
owning_ptr< Derived >( dynamic_cast< Derived * >( pB() ) );