cmDeleteAll: Generalize deletion specialization for map types.
Assume that a container whose value_type is a std::pair should have its second member deleted.
This commit is contained in:
parent
f8c416f00c
commit
4dc0c488f9
|
@ -239,7 +239,20 @@ private:
|
||||||
|
|
||||||
namespace ContainerAlgorithms {
|
namespace ContainerAlgorithms {
|
||||||
|
|
||||||
template<typename Container>
|
template<typename T>
|
||||||
|
struct cmIsPair
|
||||||
|
{
|
||||||
|
enum { value = false };
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename K, typename V>
|
||||||
|
struct cmIsPair<std::pair<K, V> >
|
||||||
|
{
|
||||||
|
enum { value = true };
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Container,
|
||||||
|
bool valueTypeIsPair = cmIsPair<typename Container::value_type>::value>
|
||||||
struct DefaultDeleter
|
struct DefaultDeleter
|
||||||
{
|
{
|
||||||
void operator()(typename Container::value_type value) {
|
void operator()(typename Container::value_type value) {
|
||||||
|
@ -247,10 +260,10 @@ struct DefaultDeleter
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename K, typename V>
|
template<typename Container>
|
||||||
struct DefaultDeleter<std::map<K, V> >
|
struct DefaultDeleter<Container, /* valueTypeIsPair = */ true>
|
||||||
{
|
{
|
||||||
void operator()(typename std::map<K, V>::value_type value) {
|
void operator()(typename Container::value_type value) {
|
||||||
delete value.second;
|
delete value.second;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue