
Jaakko, Thanks for your reply, I tried some of your suggestions and they are still giving me compile errors. Here is some code that Ive been playing with. This was compiled in VC8. struct some_functor { private: int x_; public: template<typename SOMETYPE> some_functor& template_foo(SOMETYPE x){ std::cout<<boost::format("Calling %x.%s(%d)\n") % this % __FUNCTION__%x; return *this; } }; void test16 { PRINT_FUNCTION_NAME; using namespace boost::lambda; int a[] = {1, 2, 3, 4, 5, 6, 7, 8}; std::vector<int> v(a, a+sizeof(a)/sizeof(int)); (bind(&(some_functor::template_foo<int>), some_functor(), _1))(boost::cref(1)) } The error that I'm getting is as follows. From the error information, it seems that it cant seem to find the right template of bind to instantiate. It starts to from arity 10 through arity 1. This also ties in with my question in an earlier post of using boost::format in a lambda expression. The overloaded operator in the basic_format class in the boost.format library is a template overloaded operator. 1>c:\haroon\dev\testprograms\lambda\lambda.cpp(461) : error C2780: 'const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<10,boost::lambda::function_action<10,T>>,detail::bind_tuple_mapper<const Arg1,const Arg2,const Arg3,const Arg4,const Arg5,const Arg6,const Arg7,const Arg8,const Arg9,const Arg10>::type>> boost::lambda::bind(const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &,const Arg5 &,const Arg6 &,const Arg7 &,const Arg8 &,const Arg9 &,const Arg10 &)' : expects 10 arguments - 3 provided 1> c:\haroon\dev\libs\boost\include\boost\lambda\detail\bind_functions.hpp(1743) : see declaration of 'boost::lambda::bind' 1>c:\haroon\dev\testprograms\lambda\lambda.cpp(461) : error C2780: 'const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<Arity,Act>,detail::bind_tuple_mapper<const Arg1,const Arg2,const Arg3,const Arg4,const Arg5,const Arg6,const Arg7,const Arg8,const Arg9,const Arg10>::type>> boost::lambda::bind(const Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &,const Arg5 &,const Arg6 &,const Arg7 &,const Arg8 &,const Arg9 &,const Arg10 &)' : expects 10 arguments - 3 provided 1> with 1> [ 1> Arity=10, 1> Act=boost::lambda::function_action<10> 1> ] 1> c:\haroon\dev\libs\boost\include\boost\lambda\detail\bind_functions.hpp(1710) : see declaration of 'boost::lambda::bind' More errors On 11/29/06, Jaakko Järvi <jarvi@cs.tamu.edu> wrote:
On Nov 28, 2006, at 10:44 PM, Haroon Khan wrote:
Is it possible to bind to the following functions using boost.lamdba and if so how?
class some_class { public: some_class operator % (int x) { return this }
template<typename T> void foo(T x){ } };
I use the examples given in online-documentation but it gives me a lot of errors. I'm using VC8 on windows XP.
Not exactly sure what you are after but here are a few valid ways:
some_class s; int i; ret<some_class>(var(s) % _1)(i); bind(&some_class::operator%, var(s), _1)(i); bind(&some_class::operator%, &s, _1)(i); bind(&some_class::foo<int>, var(s), _1)(i); bind(&some_class::foo<int>, &s, _1)(i);
Cheers, Jaakko
Thanks, Haroon _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users