struct DoDelete
{
template<typename T> void operator()(const T* p) const
{
delete p;
}
};
struct DoDeleteMap
{
template<typename T1, typename T2> void operator()(const pair<T1,T2>& p) const
{
delete p.second;
}
};
template <class List> void ClearList(List& lst)
{
for_each(lst.begin(), lst.end(), DoDelete());
lst.clear();
}
template <class Map> void ClearMap(Map& map)
{
for_each(map.begin(), map.end(), DoDeleteMap());
map.clear();
}
template<class T> void DoDelete(const T& p)
{
delete p;
}
template <class List> void ClearList(List& lst)
{
for_each(lst.begin(), lst.end(), boost::bind(&::DoDelete<List::value_type>, _1));
lst.clear();
}
template <class Map> void ClearMap(Map& map)
{
for_each(map.begin(), map.end(), boost::bind(&::DoDelete<Map::mapped_type>, boost::bind(&Map::value_type::second, _1)));
map.clear();
}