Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-09-15 16:17:51


Alexander Shyrokov wrote:
> I have a map<int,c*> and I would like to call a member function of the
> c* and provide a parameter to it.
>
> struct c{void f(char*){}};
> typedef std::map<int,c*> TMap;
> TMap a;
> std::for_each(a.begin(),a.end(),boost::bind(&c::f,boost::bind(&TMap::value_type::second,_1)),NULL);

You have

std::for_each( a.begin(), a.end(),

    boost::bind( &c::f,
        boost::bind( &TMap::value_type::second, _1 )
    ),

    NULL
);

but you need

std::for_each( a.begin(), a.end(),

    boost::bind( &c::f,
        boost::bind( &TMap::value_type::second, _1 ),
        NULL
    )
);


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net