Boost logo

Boost Users :

From: David Sankel (camior_at_[hidden])
Date: 2008-02-04 12:30:18


Hello,

I'm trying to use boost lambda to create a function<void (const T&)>
and I can't seem to get it to work.

Here's the setup:

class T
{
public:
    char m_c;
    T( char c ) : m_c( c )
    {
    }
    virtual T * clone() const=0;
    virtual ~T(){}
};
typedef boost::shared_ptr<T> TPtr;
typedef std::vector<TPtr> TVec;
using namespace boost::lambda;

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.

Thanks,

David

-- 
David Sankel
Sankel Software
www.sankelsoftware.com
585 617 4748 (Office)
585 309 2016 (Mobile)



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