27 Mar
2002
27 Mar
'02
1:18 a.m.
I have a hunch that this has been asked before, but I can't seem to find the answer. I have a struct similar to: struct MyStruct { int i; char c; }; And a functor similar to: struct MyFunctor { void operator()(int i) { //Do something with i } }; Given a container of MyStruct objects, how can I use iterator_adaptor to use MyStruct::i with MyFunctor? Something like: std::vector<MyStruct> v; std::for_each(v.begin(), v.end(), MyFunctor()); I have overridden the dereference method in default_iterator_policies to return the integer, but am at a bit of a loss where to go from here. Am I on the right track? TIA for your help! David Brownell