Boost logo

Boost Users :

From: rodolfo_at_[hidden]
Date: 2006-11-28 16:23:47

Hi, I'm trying to put a simple lambda functor which uses
pointer to member function into a boost::function like this:

struct aux
    int a() const { return 5; }
                                                                                                                             int main()
    function<int(const aux &)> f = &_1->*&aux::a;

But the compiler chokes at the assignment with the error:

/usr/include/boost/function/function_template.hpp:119: error: cannot
convert 'boost::lambda::detail::member_pointer_caller<int, const aux*,
int (aux::*)()const>' to 'int' in return

I think it should be able to convert the member_pointer_caller to
boost::function, as its result (int) is the same of function's result,
as well as its only argument is the one that makes the lambda
functor valid.

According to the documentation, something like this should work because
it says that

    boost::function<int(int, int)> f = _1 + _2


Am I missing something?

Thank you,
      Rodolfo Lima.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at