Actually your write_event looks like it would best suited as a function-object. Then you could call
Alternatively if you want to create MyEventWriter so you still have a copy of it after the std::for_each you can create it first, thus:Code:std::for_each( v.begin(), v.end(), MyEventWriter( my_outstream ) );
If you don't want to use operator() in evwr but a named member function instead, you can use bind.Code:MyEventWriter evwr( myOutStream ); std::for_each( v.begin(), v.end(), evwr );




Reply With Quote