diff options
author | Brad King <brad.king@kitware.com> | 2015-01-19 14:43:25 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-01-19 14:43:25 (GMT) |
commit | 95d42840e88599ab1959f7531668e320a7c20fdf (patch) | |
tree | bdc0e55f563f6c63bebd0a027034529699db0c9c | |
parent | a1fea841a92568c0bdc35e1c8c7a400b20459a96 (diff) | |
parent | 681d965df18fa55a9eaa615515015ac088ea0805 (diff) | |
download | CMake-95d42840e88599ab1959f7531668e320a7c20fdf.zip CMake-95d42840e88599ab1959f7531668e320a7c20fdf.tar.gz CMake-95d42840e88599ab1959f7531668e320a7c20fdf.tar.bz2 |
Merge topic 'delete-algorithm'
681d965d Use the cmDeleteAll algorithm for types derived from std::map.
4dc0c488 cmDeleteAll: Generalize deletion specialization for map types.
-rw-r--r-- | Source/cmExportSetMap.cxx | 7 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmStandardIncludes.h | 21 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 12 |
4 files changed, 21 insertions, 25 deletions
diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx index 5174118..14c4458 100644 --- a/Source/cmExportSetMap.cxx +++ b/Source/cmExportSetMap.cxx @@ -25,12 +25,7 @@ cmExportSet* cmExportSetMap::operator[](const std::string &name) void cmExportSetMap::clear() { - for(std::map<std::string, cmExportSet*>::iterator it = this->begin(); - it != this->end(); - ++ it) - { - delete it->second; - } + cmDeleteAll(*this); this->derived::clear(); } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d17710e..f282bad 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1510,11 +1510,7 @@ void cmGlobalGenerator::CreateGeneratorTargets() //---------------------------------------------------------------------------- void cmGlobalGenerator::ClearGeneratorMembers() { - for(cmGeneratorTargetsType::iterator i = this->GeneratorTargets.begin(); - i != this->GeneratorTargets.end(); ++i) - { - delete i->second; - } + cmDeleteAll(this->GeneratorTargets); this->GeneratorTargets.clear(); cmDeleteAll(this->EvaluationFiles); 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; } }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8e060c4..8d0271a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -539,12 +539,7 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); - for (cmTargetLinkInformationMap::const_iterator it - = this->LinkInformation.begin(); - it != this->LinkInformation.end(); ++it) - { - delete it->second; - } + cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -6874,10 +6869,7 @@ cmTargetLinkInformationMap //---------------------------------------------------------------------------- cmTargetLinkInformationMap::~cmTargetLinkInformationMap() { - for(derived::iterator i = this->begin(); i != this->end(); ++i) - { - delete i->second; - } + cmDeleteAll(*this); } //---------------------------------------------------------------------------- |