I'm having some trouble with BLL and Boost.Function in this simple
testcase:
#include
#include
#include <iostream>
class Test {
public:
void foo(int a) { std::cout << "a is " << a << std::endl; };
};
template<typename Function>
class Caller {
private:
Function func;
public:
Caller(Function f) : func(f) {};
void bar(void) { func(); };
};
int main(void)
{
Test tester;
int value = 10;
Caller >
printer(boost::lambda::bind(boost::lambda::bind(&Test::foo, tester,
boost::lambda::_1), value));
printer.bar();
return(0);
}
The g++ 4.0.3 compiler complains (full trace below):
/usr/include/boost/lambda/detail/lambda_functor_base.hpp:408: error:
invalid use of void expression
Is it not legal to bind a lambda-bound function?
-Dave
----------------------
/usr/include/boost/lambda/detail/lambda_functor_base.hpp: In member
function 'RET
boost::lambda::lambda_functor_base,
Args>::call(A&, B&, C&, Env&) const [with RET =
boost::tuples::null_type, A = const boost::tuples::null_type, B = const
boost::tuples::null_type, C = const boost::tuples::null_type, Env =
const boost::tuples::null_type, Act = boost::lambda::function_action<2,
boost::lambda::detail::unspecified>, Args = boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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>]':
/usr/include/boost/lambda/detail/lambda_functors.hpp:140: instantiated
from 'typename T::sigboost::tuples::null_type::type
boost::lambda::lambda_functor<Base>::operator()() const [with T =
boost::lambda::lambda_functor_base >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> >]'
/usr/include/boost/function/function_template.hpp:136: instantiated
from 'static void
boost::detail::function::void_function_obj_invoker0::invoke(boost::detail::function::any_pointer) [with FunctionObj =
boost::lambda::lambda_functor >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> > >, R = void]'
/usr/include/boost/function/function_template.hpp:479: instantiated
from 'void boost::function0::assign_to(FunctionObj,
boost::detail::function::function_obj_tag) [with FunctionObj =
boost::lambda::lambda_functor >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> > >, R = void, Allocator = std::allocator<void>]'
/usr/include/boost/function/function_template.hpp:430: instantiated
from 'void boost::function0::assign_to(Functor) [with
Functor =
boost::lambda::lambda_functor >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> > >, R = void, Allocator = std::allocator<void>]'
/usr/include/boost/function/function_template.hpp:294: instantiated
from 'boost::function0::function0(Functor, typename
boost::enable_if_c::value,
int>::type) [with Functor =
boost::lambda::lambda_functor >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> > >, R = void, Allocator = std::allocator<void>]'
/usr/include/boost/function/function_template.hpp:637: instantiated
from 'boost::function::function(Functor, typename
boost::enable_if_c::value,
int>::type) [with Functor =
boost::lambda::lambda_functor >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> > >, R = void, Allocator = std::allocator<void>]'
lambda3.cc:27: instantiated from here
/usr/include/boost/lambda/detail/lambda_functor_base.hpp:408: error:
invalid use of void expression
/usr/include/boost/lambda/detail/actions.hpp: In static member function
'static RET boost::lambda::function_action<3, T>::apply(A1&, A2&, A3&)
[with RET = void, A1 = void (Test::* const)(int), A2 = const Test, A3 =
const boost::tuples::null_type, T = boost::lambda::detail::unspecified]':
/usr/include/boost/lambda/detail/lambda_functor_base.hpp:425:
instantiated from 'RET
boost::lambda::lambda_functor_base,
Args>::call(A&, B&, C&, Env&) const [with RET = void, A = const
boost::tuples::null_type, B = const boost::tuples::null_type, C = const
boost::tuples::null_type, Env = const boost::tuples::null_type, Act =
boost::lambda::function_action<3, boost::lambda::detail::unspecified>,
Args = boost::tuples::tuple >,
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>]'
/usr/include/boost/lambda/detail/select_functions.hpp:61: instantiated
from 'static RET boost::lambda::detail::r_select<RET>::go(const
boost::lambda::lambda_functor<Arg>&, A&, B&, C&, Env&) [with Arg =
boost::lambda::lambda_functor_base >,
boost::tuples::tuple >,
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> >, A = const boost::tuples::null_type, B =
const boost::tuples::null_type, C = const boost::tuples::null_type, Env
= const boost::tuples::null_type, RET = void]'
/usr/include/boost/lambda/detail/lambda_functor_base.hpp:408:
instantiated from 'RET
boost::lambda::lambda_functor_base,
Args>::call(A&, B&, C&, Env&) const [with RET =
boost::tuples::null_type, A = const boost::tuples::null_type, B = const
boost::tuples::null_type, C = const boost::tuples::null_type, Env =
const boost::tuples::null_type, Act = boost::lambda::function_action<2,
boost::lambda::detail::unspecified>, Args = boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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>]'
/usr/include/boost/lambda/detail/lambda_functors.hpp:140: instantiated
from 'typename T::sigboost::tuples::null_type::type
boost::lambda::lambda_functor<Base>::operator()() const [with T =
boost::lambda::lambda_functor_base >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> >]'
/usr/include/boost/function/function_template.hpp:136: instantiated
from 'static void
boost::detail::function::void_function_obj_invoker0::invoke(boost::detail::function::any_pointer) [with FunctionObj =
boost::lambda::lambda_functor >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> > >, R = void]'
/usr/include/boost/function/function_template.hpp:479: instantiated
from 'void boost::function0::assign_to(FunctionObj,
boost::detail::function::function_obj_tag) [with FunctionObj =
boost::lambda::lambda_functor >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> > >, R = void, Allocator = std::allocator<void>]'
/usr/include/boost/function/function_template.hpp:430: instantiated
from 'void boost::function0::assign_to(Functor) [with
Functor =
boost::lambda::lambda_functor >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> > >, R = void, Allocator = std::allocator<void>]'
/usr/include/boost/function/function_template.hpp:294: instantiated
from 'boost::function0::function0(Functor, typename
boost::enable_if_c::value,
int>::type) [with Functor =
boost::lambda::lambda_functor >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> > >, R = void, Allocator = std::allocator<void>]'
/usr/include/boost/function/function_template.hpp:637: instantiated
from 'boost::function::function(Functor, typename
boost::enable_if_c::value,
int>::type) [with Functor =
boost::lambda::lambda_functor >,
boost::tuples::tuple >,
boost::tuples::tuple >,
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> > >, const int, 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> > >, R = void, Allocator = std::allocator<void>]'
lambda3.cc:27: instantiated from here
/usr/include/boost/lambda/detail/actions.hpp:96: error: no matching
function for call to 'boost::lambda::function_adaptor::apply(void (Test::* const&)(int), const Test&, const
boost::tuples::null_type&)'
/usr/include/boost/lambda/detail/function_adaptors.hpp:245: note:
candidates are: static Result boost::lambda::function_adaptor::apply(Result (Object::*)(Arg1), Object*, A1&) [with
RET = void, A1 = const boost::tuples::null_type, Object = Test, Arg1 =
int, Result = void]
/usr/include/boost/lambda/detail/function_adaptors.hpp:249: note:
static Result boost::lambda::function_adaptor::apply(Result (Object::*)(Arg1), Object&, A1&) [with
RET = void, A1 = const boost::tuples::null_type, Object = Test, Arg1 =
int, Result = void]
/usr/include/boost/lambda/detail/actions.hpp:96: error: return-statement
with a value, in function returning 'void'