
28 Nov
2007
28 Nov
'07
10:13 a.m.
I'm trying to use boost::bind - and I'm probably doing something very obviously wrong, but code blindness has set in. A simple example: I have class X { public: void t(int a, int b) { cout << a * b << endl; } }; then in main... vector<int> v; // filled with some ints for_each(v.begin(), v.end(), boost::bind(&X::t, _1, 4)); // or _1, 4 But this doesn't compile - using Borland Turbo C++ (or Visual C++) Elsewhere in my code I use for_each(istream_iterator<string>(f), istream_iterator<string>(), boost::bind(Inserter<T>(), boost::ref(m), _1)); Which works just fine... I'm sure it's something strikingly obvious - but as far as I can see I'm doing much the same as in the docs ? Thanks for any comments. Martin