diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-01-04 14:16:56 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-01-17 15:22:58 (GMT) |
commit | 4dc0c488f94a5f0c7ae04fd15b46a92c20fb03fa (patch) | |
tree | 50be33d3ed350b4e3110e0a687738310f51b8934 /Source/cmStandardIncludes.h | |
parent | f8c416f00c9d263556cca9d9dfc0c71913bdd7f3 (diff) | |
download | CMake-4dc0c488f94a5f0c7ae04fd15b46a92c20fb03fa.zip CMake-4dc0c488f94a5f0c7ae04fd15b46a92c20fb03fa.tar.gz CMake-4dc0c488f94a5f0c7ae04fd15b46a92c20fb03fa.tar.bz2 |
cmDeleteAll: Generalize deletion specialization for map types.
Assume that a container whose value_type is a std::pair should have
its second member deleted.
Diffstat (limited to 'Source/cmStandardIncludes.h')
-rw-r--r-- | Source/cmStandardIncludes.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 251a043..646300d 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -239,7 +239,20 @@ private: 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 { void operator()(typename Container::value_type value) { @@ -247,10 +260,10 @@ struct DefaultDeleter } }; -template<typename K, typename V> -struct DefaultDeleter<std::map<K, V> > +template<typename Container> +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; } }; |