In a destructor for a class, I had a std::vector of pointers that I wanted to delete. I started to write the usual for(;;) loop and realized I do this often enough I should make it easy to use std::for_each().

Here’s the functor (based on std::unary_function):

And here’s some sample code using it:

I added a return of true because some other template code wasn’t happy about “return void” — supposedly something fixed in recent compilers.