
This doesn't compile. How best to accomplish this using generic STL or Boost algorithms/adapters? terry #include <iostream> #include <iomanip> #include <algorithm> #include <vector> #include <iterator> #include <cstdlib> #include <boost/bind.hpp> #include <boost/mem_fn.hpp> using namespace std; using namespace boost; class MyInt { int _value; public: explicit MyInt(int x=0) : _value(x) { } int value() const { return _value; } }; // MyInt int main() { vector<MyInt> v; // Do this: // for (int i=0; i!=30; ++i) v.push_back(MyInt(rand())); generate_n(back_inserter(v), 30, bind(MyInt, bind(rand))); // Now print v. transform(v.begin(), v.end(), ostream_iterator<int>(cout, "\n"), mem_fn(&MyInt::value)); return 0; } // main