$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-11-28 17:13:35
rodolfo_at_[hidden] wrote:
> 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
Try
    function<int(const aux &)> f = (&_1->*&aux::a)();
or
    function<int(const aux &)> f = bind( &aux::a, _1 );
or
    function<int(const aux &)> f = &aux::a;