// ----------------------------------------------------------- #include #include #include #include #include using namespace std; using namespace boost; int initValue = 0; class myClass { public: myClass(): mValue(initValue) {} myClass(const myClass& rhs): mValue(initValue++) { } void func() { cout << mValue << endl; } private: int mValue; }; typedef vector vocType; typedef vector vovType; int main() { vovType vov(10, vocType(10, myClass())); for_each(vov.begin(), vov.end(), bind(for_each< vocType::iterator, function >, bind(&vocType::begin, _1), bind(&vocType::end, _1), protect(bind(&myClass::func, _1)) ) ); } // -----------------------------------------------------------