
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)