Boost logo

Boost Users :

From: Boris (boriss_at_[hidden])
Date: 2007-03-12 09:15:02


struct sample
{
        int i;
        sample(int i) : i(i) { }
        bool odd() { return i % 2; }
};

template <class T, class U>
std::basic_ostream<T, U> &operator<<(std::basic_ostream<T, U>& ostr,
sample s) { return ostr << s.i; }

std::vector<sample> from;
std::vector<sample> to;

from.push_back(sample(1));
from.push_back(sample(2));
from.push_back(sample(3));

// Why doesn't this compile ...
std::for_each(from.begin(), from.end(), if_then((_1 ->* &sample::odd) ==
false, std::cout << _1));

// ... but this does? Isn't it the same?
std::for_each(from.begin(), from.end(), if_then(bind(&sample::odd, _1) ==
false, std::cout << _1));

Thanks in advance for any explanation which helps me to understand lamba
expressions better,
Boris


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