summaryrefslogtreecommitdiffstats
path: root/Source/cmAlgorithms.h
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-03-08 08:43:11 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-03-10 23:17:55 (GMT)
commit8701a3f468a4fb684442a8a9c5d4c8d15c72eb7b (patch)
tree8076a7cd54738e6a9c9357088bc261e1cf6570cb /Source/cmAlgorithms.h
parenteec7091d76fc3db6535eec3f78fd2585b9c0c38a (diff)
downloadCMake-8701a3f468a4fb684442a8a9c5d4c8d15c72eb7b.zip
CMake-8701a3f468a4fb684442a8a9c5d4c8d15c72eb7b.tar.gz
CMake-8701a3f468a4fb684442a8a9c5d4c8d15c72eb7b.tar.bz2
cmRemoveDuplicates: Partially specialize the API for pointer types.
If de-duplicating a container of pointers, there is no need to store iterators to them, as that is just more 'pointer chasing'. Store the pointers themselves and use API which compares the pointers in the specialization.
Diffstat (limited to 'Source/cmAlgorithms.h')
-rw-r--r--Source/cmAlgorithms.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 5504fee..0cf7701 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -263,7 +263,7 @@ typename Range::const_iterator cmRemoveMatching(Range &r, MatchRange const& m)
namespace ContainerAlgorithms {
-template<typename Range>
+template<typename Range, typename T = typename Range::value_type>
struct RemoveDuplicatesAPI
{
typedef typename Range::const_iterator const_iterator;
@@ -275,6 +275,18 @@ struct RemoveDuplicatesAPI
static bool valueCompare(It it, const_iterator it2) { return **it != *it2; }
};
+template<typename Range, typename T>
+struct RemoveDuplicatesAPI<Range, T*>
+{
+ typedef typename Range::const_iterator const_iterator;
+ typedef T* value_type;
+
+ static bool lessThan(value_type a, value_type b) { return a < b; }
+ static value_type uniqueValue(const_iterator a) { return *a; }
+ template<typename It>
+ static bool valueCompare(It it, const_iterator it2) { return *it != *it2; }
+};
+
}
template<typename Range>