Subject: Re: [boost] intrusive_ptr design question
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-07-06 10:23:22
-----BEGIN PGP SIGNED MESSAGE-----
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)
-----END PGP SIGNATURE-----