Is it possible to use boost::ref() or boost::lambda::var() of an
abstract class as a parameter to boost::lambda::bind()?
It seems that compiler attempts to instantiate an object of that
abstract class.
Example:
-----------------
using namespace boost;
using namespace boost::lambda;
class Y
{
public:
virtual void foo() = 0;
void foo2 (){ }
};
class Z : public Y
{
public:
void foo(){}
};
class TT
{
public:
void test( Y& y ) { y.foo2(); }
};
int main()
{
std::vector<TT> xt;
Z z;
Y &y = z;
std::for_each (xt.begin(), xt.end(), bind(&TT::test,_1,
ref(y)));
return 0;
}
----------------------
And Error message from g++ (GCC) 3.2.3:
---------------------------------
/boost/tuple/detail/tuple_basic.hpp: In instantiation of
`boost::tuples::cons':
/boost/tuple/detail/tuple_basic.hpp:326: instantiated from
`boost::tuples::cons >'
/boost/tuple/detail/tuple_basic.hpp:326: instantiated from
`boost::tuples::cons > >'
/boost/lambda/detail/lambda_functor_base.hpp:151: instantiated from
`boost::lambda::detail::has_null_type > > >'
/boost/lambda/detail/lambda_functor_base.hpp:229: instantiated from
`boost::lambda::detail::deduce_non_ref_argument_types >, Y&,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type>, boost::tuples::null_type>'
/boost/lambda/detail/lambda_functor_base.hpp:412: instantiated from
`boost::lambda::lambda_functor_base >,
boost::tuples::tuple >, Y&,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type> >::sigboost::tuples::null_type'
/boost/lambda/detail/lambda_functors.hpp:135: instantiated from
`boost::lambda::lambda_functor >, boost::tuples::tuple >, Y&,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type> > >'
lamtest.cpp:35: instantiated from here
/boost/tuple/detail/tuple_basic.hpp:320: cannot
declare field `boost::tuples::cons::head'
to be
of type `Y'
/boost/tuple/detail/tuple_basic.hpp:320:
because the following virtual functions are abstract:
lamtest.cpp:12: virtual void Y::foo()
----------------------------------------
Thanks,
Eugene Vishnevetsky
--------------------------------------------------------
NOTICE: If received in error, please destroy and notify sender. Sender does not waive confidentiality or privilege, and use is prohibited.