summaryrefslogtreecommitdiff
path: root/include/comphelper
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-11-06 11:48:35 +0100
committerMichael Stahl <mstahl@redhat.com>2015-11-06 12:59:55 +0000
commiteaf640d282dd2bd8f647a510e401323da506a810 (patch)
tree83cd0de8a58d18ae95333c6f50ce0e8cb66cfdb6 /include/comphelper
parent5c3ccc9e4a749a6358d29d20533ff11fa48aa602 (diff)
comphelper: add a generic implementation of std container operator==
... that contain std::unique_ptr. With C++11 variadic templates this apparently works for both std::vector and std::set; associative containers like std::map have different iterators so need a different implementation. Change-Id: I6872445b007875c310d08fa7a8d7311075880b1d Reviewed-on: https://gerrit.libreoffice.org/19818 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'include/comphelper')
-rw-r--r--include/comphelper/stl_types.hxx23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/comphelper/stl_types.hxx b/include/comphelper/stl_types.hxx
index 84ea999b0776..f154937bd507 100644
--- a/include/comphelper/stl_types.hxx
+++ b/include/comphelper/stl_types.hxx
@@ -100,6 +100,29 @@ template<class T> struct UniquePtrValueLess
}
};
+/// by-value implementation of std::foo<std::unique_ptr<T>>::operator==
+template<template<typename, typename...> class C, typename T, typename... Etc>
+bool ContainerUniquePtrEquals(
+ C<std::unique_ptr<T>, Etc...> const& lhs,
+ C<std::unique_ptr<T>, Etc...> const& rhs)
+{
+ if (lhs.size() != rhs.size())
+ {
+ return false;
+ }
+ for (auto iter1 = lhs.begin(), iter2 = rhs.begin();
+ iter1 != lhs.end();
+ ++iter1, ++iter2)
+ {
+ if (!(**iter1 == **iter2))
+ {
+ return false;
+ }
+ }
+ return true;
+};
+
+
/** STL-compliant structure for comparing Reference&lt; &lt;iface&gt; &gt; instances
*/
template < class IAFCE >