« Return to Thread: intrusive_ptr design question

Re: intrusive_ptr design question

by Frank Mori Hess :: Rate this Message:

Reply to Author | View in Thread

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 06 July 2009, Zachary Turner wrote:

> >
> > One of the main reasons for intrusive_ptr is to have smart pointers to
> > third-party classes that already have their own refcount. Since you
> > can't add a member to a class you don't control, using member functions
> > to manipulate the refcount would rule out that use. The expectation in
> > this case would be that the user would write these two free functions to
> > just call the appropriate member functions on the third-party class.
>
> But why not just allow the intrusive_ptr to accept those free
> functions as constructor arguments, allowing me to pass different free
> functions for different instances?

Because you'd have to store 2 function pointers in every intrusive_ptr object?  
Why don't you just store the function pointers in your class?  Then for
example intrusive_ptr_add_ref can call some member function of your class,
which in turn calls its object's internal function pointer.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpSCNoACgkQ5vihyNWuA4UQ8QCeIx4/EO6K8wWBFhe6ZRKzNAMC
Zf8AoNRlsNgAqoJvpHiHtGB0XKQEjqqr
=wGgt
-----END PGP SIGNATURE-----
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

 « Return to Thread: intrusive_ptr design question