summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/comphelper/stl_types.hxx23
-rw-r--r--sc/source/core/tool/dbdata.cxx24
2 files changed, 27 insertions, 20 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 >
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index cdf0ff083951..5f145fa444d9 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -34,6 +34,8 @@
#include "dociter.hxx"
#include "brdcst.hxx"
+#include <comphelper/stl_types.hxx>
+
#include <memory>
#include <utility>
@@ -1169,18 +1171,7 @@ size_t ScDBCollection::NamedDBs::size() const
bool ScDBCollection::NamedDBs::operator== (const NamedDBs& r) const
{
- if (m_DBs.size() != r.m_DBs.size())
- {
- return false;
- }
- for (auto iter1 = m_DBs.begin(), iter2 = r.m_DBs.begin(); iter1 != m_DBs.end(); ++iter1, ++iter2)
- {
- if (**iter1 != **iter2)
- {
- return false;
- }
- }
- return true;
+ return ::comphelper::ContainerUniquePtrEquals(m_DBs, r.m_DBs);
}
ScDBCollection::AnonDBs::iterator ScDBCollection::AnonDBs::begin()
@@ -1257,14 +1248,7 @@ bool ScDBCollection::AnonDBs::has( const ScDBData* p ) const
bool ScDBCollection::AnonDBs::operator== (const AnonDBs& r) const
{
- if (m_DBs.size() != r.m_DBs.size())
- return false;
- for (auto iter1 = begin(), iter2 = r.begin(); iter1 != end(); ++iter1, ++iter2)
- {
- if (**iter1 != **iter2)
- return false;
- }
- return true;
+ return ::comphelper::ContainerUniquePtrEquals(m_DBs, r.m_DBs);
}
ScDBCollection::AnonDBs::AnonDBs()