Hi All, I came across this strange error. Binding of overloaded member
functions works with boost bind, but not with boost lambda bind. Here
is the example
Following builds and works fine
#include "boost/function.hpp"
#include "boost/bind.hpp"
class Operations
{
public:
void Fun1( int i ){ std::cout<<"\nfunction with one arg\n"; }
void Fun1( int i, double d) {std::cout<<"\nfunction with two args\n"; }
};
-----------------------
int main()
{
Operations op;
typedef boost::function fptr;
fptr func1 = boost::bind( &Operations::Fun1, &op,1);
fptr func2 = boost::bind( &Operations::Fun1, &op, 1, 2.2 );
return 0;
}
------------------------
While following Does not compile
int main()
{
using namespace boost::lambda;
Operations op;
typedef boost::function fptr;
fptr func1 = bind( &Operations::Fun1, &op,1);
fptr func2 = bind( &Operations::Fun1, &op, 1, 2.2 );
return 0
}
-------------------------
This spits out massive error, as shown below. I think gist of which is
it can't figure out which function to instantiate, when using lambda
bind. Can some body please point out what am I missing here ?
(Sorry for long email, I didn't wanted to clutter the email with this
error message, bu thought most of you will figure it out just from
looking at it.).
Any help will be appreciated, and thanks in advance.
Kaz
boostFunctionAndBind.cpp: In function ‘int main()’:
boostFunctionAndBind.cpp:61:45: error: no matching function for call
to ‘bind(<unresolved overloaded function type>, Operations*, int)’
boostFunctionAndBind.cpp:61:45: note: candidates are:
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:49:1: note:
template<class Result> const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(Result (&)())
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:71:1: note:
template<class Arg1> const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper<const Arg1>::type> >
boost::lambda::bind(const Arg1&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:91:1: note:
template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper<const Arg1>::type> >
boost::lambda::bind(const Arg1&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:190:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(Result (&)(Par1), const Arg2&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:212:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:232:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:333:1:
note: template const boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(Result (&)(Par1, Par2),
const Arg2&, const Arg3&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:361:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&, const
Arg3&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:387:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&, const
Arg3&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:503:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(Result (&)(Par1, Par2, Par3), const Arg2&, const
Arg3&, const Arg4&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:532:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const
Arg2&, const Arg3&, const Arg4&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:558:1:
note: template const boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const
Arg2&, const Arg3&, const Arg4&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:679:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(Result (&)(Par1, Par2, Par3, Par4), const Arg2&,
const Arg3&, const Arg4&, const Arg5&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:710:1:
note: template const boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const
Arg1&, const Arg2&, const Arg3&, const Arg4&, const Arg5&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:738:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const
Arg1&, const Arg2&, const Arg3&, const Arg4&, const Arg5&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:867:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(Result (&)(Par1, Par2, Par3, Par4,
Par5), const Arg2&, const Arg3&, const Arg4&, const Arg5&, const
Arg6&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:899:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(const Arg1&, const Arg2&, const Arg3&, const
Arg4&, const Arg5&, const Arg6&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:927:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(const Arg1&, const Arg2&, const Arg3&, const
Arg4&, const Arg5&, const Arg6&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1058:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(Result (&)(Par1,
Par2, Par3, Par4, Par5, Par6), const Arg2&, const Arg3&, const Arg4&,
const Arg5&, const Arg6&, const Arg7&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1092:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(const Arg1&, const Arg2&, const Arg3&, const
Arg4&, const Arg5&, const Arg6&, const Arg7&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1123:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(const Arg1&, const Arg2&, const Arg3&, const
Arg4&, const Arg5&, const Arg6&, const Arg7&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1257:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(Result (&)(Par1, Par2, Par3, Par4, Par5, Par6,
Par7), const Arg2&, const Arg3&, const Arg4&, const Arg5&, const
Arg6&, const Arg7&, const Arg8&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1291:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&, const
Arg3&, const Arg4&, const Arg5&, const Arg6&, const Arg7&, const
Arg8&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1322:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&, const
Arg3&, const Arg4&, const Arg5&, const Arg6&, const Arg7&, const
Arg8&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1458:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(Result (&)(Par1, Par2, Par3, Par4, Par5, Par6,
Par7, Par8), const Arg2&, const Arg3&, const Arg4&, const Arg5&, const
Arg6&, const Arg7&, const Arg8&, const Arg9&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1494:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&,
const Arg3&, const Arg4&, const Arg5&, const Arg6&, const Arg7&, const
Arg8&, const Arg9&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1526:1:
note: template
const boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&,
const Arg3&, const Arg4&, const Arg5&, const Arg6&, const Arg7&, const
Arg8&, const Arg9&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1673:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(Result (&)(Par1, Par2, Par3,
Par4, Par5, Par6, Par7, Par8, Par9), const Arg2&, const Arg3&, const
Arg4&, const Arg5&, const Arg6&, const Arg7&, const Arg8&, const
Arg9&, const Arg10&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1710:1:
note: template
const boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&,
const Arg2&, const Arg3&, const Arg4&, const Arg5&, const Arg6&, const
Arg7&, const Arg8&, const Arg9&, const Arg10&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1743:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&,
const Arg2&, const Arg3&, const Arg4&, const Arg5&, const Arg6&, const
Arg7&, const Arg8&, const Arg9&, const Arg10&)
boostFunctionAndBind.cpp:62:52: error: no matching function for call
to ‘bind(<unresolved overloaded function type>, Operations*, int,
double)’
boostFunctionAndBind.cpp:62:52: note: candidates are:
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:49:1: note:
template<class Result> const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(Result (&)())
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:71:1: note:
template<class Arg1> const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper<const Arg1>::type> >
boost::lambda::bind(const Arg1&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:91:1: note:
template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper<const Arg1>::type> >
boost::lambda::bind(const Arg1&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:190:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(Result (&)(Par1), const Arg2&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:212:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:232:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:333:1:
note: template const boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(Result (&)(Par1, Par2),
const Arg2&, const Arg3&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:361:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&, const
Arg3&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:387:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&, const
Arg3&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:503:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(Result (&)(Par1, Par2, Par3), const Arg2&, const
Arg3&, const Arg4&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:532:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const
Arg2&, const Arg3&, const Arg4&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:558:1:
note: template const boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const
Arg2&, const Arg3&, const Arg4&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:679:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(Result (&)(Par1, Par2, Par3, Par4), const Arg2&,
const Arg3&, const Arg4&, const Arg5&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:710:1:
note: template const boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const
Arg1&, const Arg2&, const Arg3&, const Arg4&, const Arg5&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:738:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const
Arg1&, const Arg2&, const Arg3&, const Arg4&, const Arg5&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:867:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(Result (&)(Par1, Par2, Par3, Par4,
Par5), const Arg2&, const Arg3&, const Arg4&, const Arg5&, const
Arg6&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:899:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(const Arg1&, const Arg2&, const Arg3&, const
Arg4&, const Arg5&, const Arg6&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:927:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(const Arg1&, const Arg2&, const Arg3&, const
Arg4&, const Arg5&, const Arg6&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1058:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(Result (&)(Par1,
Par2, Par3, Par4, Par5, Par6), const Arg2&, const Arg3&, const Arg4&,
const Arg5&, const Arg6&, const Arg7&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1092:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(const Arg1&, const Arg2&, const Arg3&, const
Arg4&, const Arg5&, const Arg6&, const Arg7&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1123:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(const Arg1&, const Arg2&, const Arg3&, const
Arg4&, const Arg5&, const Arg6&, const Arg7&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1257:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(Result (&)(Par1, Par2, Par3, Par4, Par5, Par6,
Par7), const Arg2&, const Arg3&, const Arg4&, const Arg5&, const
Arg6&, const Arg7&, const Arg8&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1291:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&, const
Arg3&, const Arg4&, const Arg5&, const Arg6&, const Arg7&, const
Arg8&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1322:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&, const
Arg3&, const Arg4&, const Arg5&, const Arg6&, const Arg7&, const
Arg8&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1458:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> >
boost::lambda::bind(Result (&)(Par1, Par2, Par3, Par4, Par5, Par6,
Par7, Par8), const Arg2&, const Arg3&, const Arg4&, const Arg5&, const
Arg6&, const Arg7&, const Arg8&, const Arg9&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1494:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&,
const Arg3&, const Arg4&, const Arg5&, const Arg6&, const Arg7&, const
Arg8&, const Arg9&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1526:1:
note: template
const boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&, const Arg2&,
const Arg3&, const Arg4&, const Arg5&, const Arg6&, const Arg7&, const
Arg8&, const Arg9&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1673:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(Result (&)(Par1, Par2, Par3,
Par4, Par5, Par6, Par7, Par8, Par9), const Arg2&, const Arg3&, const
Arg4&, const Arg5&, const Arg6&, const Arg7&, const Arg8&, const
Arg9&, const Arg10&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1710:1:
note: template
const boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&,
const Arg2&, const Arg3&, const Arg4&, const Arg5&, const Arg6&, const
Arg7&, const Arg8&, const Arg9&, const Arg10&)
/boost_1_49_0_beta1/boost/lambda/detail/bind_functions.hpp:1743:1:
note: template const
boost::lambda::lambda_functor >, typename
boost::lambda::detail::bind_tuple_mapper::type> > boost::lambda::bind(const Arg1&,
const Arg2&, const Arg3&, const Arg4&, const Arg5&, const Arg6&, const
Arg7&, const Arg8&, const Arg9&, const Arg10&)
make: *** [functionAndBindTest] Error 1