Jean-François Brouillet wrote:
http://boost.org/libs/smart_ptr/intrusive_ptr.html#constructors
The above link only has this to say:
constructors
intrusive_ptr(); // never throws Postconditions: get() == 0.
Throws: nothing.
intrusive_ptr(T * p, bool add_ref = true); Effects: if(p != 0 && add_ref) intrusive_ptr_add_ref(p);.
Postconditions: get() == p.
[...] Right, so you can't call it a bug if the implementation does exactly as stated. ;-)
That settles it then.
I just cannot use intrusive_ptr. Since shared_ptr is already ruled out, well .... roll-my-own-time, I guess ...
Too bad for my use of boost.
<shrug>
I'm pretty sure that a shared_ptr-based port can closely approximate the
original, but a custom smart pointer would probably be a better choice for
idiomatic Java code.
As for intrusive_ptr, its main strength is that it has the size of a
pointer. Adding a boolean would likely meet serious opposition.
Your requirements are very interesting, however, and point to a
shared/intrusive hybrid along the lines of:
template<class T> class intrusive_ptr_2
{
T * px_;
intrusive_ptr<Object> pn_;
// insert smart pointer boilerplate here ;-)
};
It's an intrusive pointer that's close to shared_ptr in expressive power;
you can use it to point to a subobject, for example.
Extending intrusive_ptr to accommodate the above along the lines of
template