Boost logo

Boost Users :

From: Nat Goodspeed (nat_at_[hidden])
Date: 2007-09-25 11:11:44


Fei Liu wrote:

> using namespace std;
> using namespace boost::lambda;
> using namespace boost;
> using boost::any_cast;
>
> int main(){
> vector<any> a;
>
> std::for_each(a.begin, a.end(), if_then(_1.type() == typeid(int))[cout
> << _1 << ' ']);
> }

Invoking a method on a placeholder is a documented limitation:

http://boost.org/doc/html/lambda/le_in_details.html#id1244744

The '.' operator cannot be overloaded. Therefore you must use bind().
Because you're using boost::lambda::if_then, I'm sure you're better off
using boost::lambda::bind than plain boost::bind, though the fact that
both have been brought into the current namespace makes me think that an
explicit reference might help -- something like:

boost::lambda::bind(&any::type, _1)

(Disclaimer: I haven't tried to compile your example, with or without my
suggestion.)


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