22 Nov
2005
22 Nov
'05
2:14 a.m.
template< typename T > boost::function
foo( T n_ ) { //Works, but leaks n //T *n = new T( n_ ); //Doesn't work boost::shared_ptr<T> n( new T(n_) );
return ( *n += _1 );
I think that you need to wrap n in boost::lambda::constant:
return *constant(n) += _1;
Without it, *n is evaluated immediately.
}
Peter,
Thanks for the reply. I must be doing something dumb, because now I'm
getting a build error.
I think this *might* be the important part:
/usr/include/boost/detail/is_incrementable.hpp:59: error: no match for
'operator++' in
'++boost::detail::is_incrementable_::impl