
26 Jul
2010
26 Jul
'10
10:13 p.m.
On Mon, Jul 26, 2010 at 3:05 PM, Steve Lorimer
I'm using boost::bind to convert a function of the form: T::fun(boost::intrusive_ptr<U>) into a form which can be stored by boost::function. Outputting calls to intrusive_ptr_add_ref and intrusive_ptr_release reveals there are a massive number of copies of the intrusive_ptr.
By design, boost::bind copies the objects it's passed. The refcounts can't be optimized out because they are a result of making actual copies. If you want boost::bind to only keep a reference to the objects you're passing to it, use boost::ref or boost::cref. For example, instead of bind(foo,a) use bind(foo,ref(a)). HTH Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode