summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Base')
-rw-r--r--Swiften/Base/Algorithm.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/Swiften/Base/Algorithm.h b/Swiften/Base/Algorithm.h
index c481aa8..108dbe3 100644
--- a/Swiften/Base/Algorithm.h
+++ b/Swiften/Base/Algorithm.h
@@ -125,31 +125,39 @@ namespace Swift {
/*
* Functors
*/
template<typename K, typename V>
class PairFirstEquals {
public:
PairFirstEquals(const K& value) : value(value) {
}
bool operator()(const std::pair<K,V>& pair) const {
return pair.first == value;
}
private:
K value;
};
template<typename K, typename V>
class PairSecondEquals {
public:
PairSecondEquals(const V& value) : value(value) {
}
bool operator()(const std::pair<K,V>& pair) const {
return pair.second == value;
}
private:
V value;
};
+
+ template <typename Map>
+ bool key_compare(Map const& lhs, Map const& rhs) {
+
+ auto pred = [](decltype(*lhs.begin()) a, decltype(a) b) { return a.first == b.first; };
+
+ return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin(), pred);
+ }
}