Suppose I have a STL map where the values are pointers, and I want to delete them all. How would I represent the following code, but making use of std::for_each? I\'m happy for
OK, I found out how to do it in one line... but I don't think I would ever actually do the following in real code!
std::for_each( mayMap.begin()
, myMap.end()
, boost::bind( &boost::checked_delete
, boost::bind( &stdext::hash_map::value_type::second, _1 ) ) );
However I'm going to accept GMan's answer because I like his idea of a wrapped container, and my answer, despite being one line as requested, is just plain nasty.