Hey
To remove all elements from a std::vector i do the following
vector<Object*> objects;
// deleting
for_each(objects.begin(), objects.end(), boost::checked_deleter<Object>());
objects.clear();
But how do I make this work for more complexed cases as a std::map?
Currently I have this, that works for std::map since it uses a std::pair internally:
template<class K, class V>
struct checked_deleter_pair
{
void operator()(std::pair<K, V*> x) const
{
boost::checked_delete(x.second);
}
};
But this is hard coded for a std container that contains a std::pair, are there a way to do this more generally?
Lizard