Boost logo

Boost Users :

From: Mark Santaniello \(AMD\) (b-marks_at_[hidden])
Date: 2005-11-21 21:14:35


> > template< typename T >
> > boost::function<T(T)> 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<boost::shared_ptr<int> >::x'

The 799B source file is here:
http://mark.santaniello.net/files/hof2.cpp

The 19KB error message is here:
http://mark.santaniello.net/files/err.txt

:)

-Mark


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net