Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-02-04 13:09:43


AMDG

David Sankel wrote:
> This works:
>
> const boost::function< void( T const * const) > f =
> bind( &TVec::push_back, &tVec,
> bind( constructor<TPtr>(),
> bind( &T::clone, _1)));
>
> But this doesn't:
>
> const boost::function< void( const T & ) > g =
> bind( &TVec::push_back, &tVec,
> bind( constructor<TPtr>(),
> bind( &T::clone, boost::cref(_1) )));
>
> The compilation error I'm getting is that it cannot create a new
> object of type T and that is expected since T is abstract. Why would
> lambda be making copies instead of passing on the reference?
>
> I've attached a simplified version of the problem.
>

There is no need to wrap _1 in cref. Boost.Lambda will pass the
arguments by
reference anyway.

In Christ,
Steven Watanabe


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