I'm taking a look at the Lambda library, and writing some toy programs, and I keep coming up with errors, and I can't figure out what the problems are....
Example 1: This works as expected:
using namespace boost::lambda;
class Foo { public: void print() { std::cout << "Foo::print()\n"; } };
template
Function for_all(Container cont, Function f) { return std::for_each(cont.begin(), cont.end(), f); } int main(int argc, char* argv[]) { std::vector<Foo> vec; //Fill vec for_all(vec, (bind(&Foo::print, _1))); return 0; }
If I change the declaration of for_all to take the container by const reference, I get errors [See Error 1 pasted in below]:
As you should, because Foo::print() is a non-const member function. Jeff F