summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorStephen Cprek <smcprek@us.ibm.com>2017-09-25 12:49:21 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2017-10-10 13:33:40 -0400
commit784ba67b9ddfab853a61ccab96648707f3fd8f88 (patch)
tree9c11dd578a1e28d8258be42b70561ef99e1bcd6f /src/include
parent0213310e21b2c375a4f80aeffd38a959533c0024 (diff)
downloadtalos-hostboot-784ba67b9ddfab853a61ccab96648707f3fd8f88.tar.gz
talos-hostboot-784ba67b9ddfab853a61ccab96648707f3fd8f88.zip
Add std::map operator== overload and != for vector
Change-Id: I3b40533d2586d455db184e9d845618b41b848296 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/46712 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com> Reviewed-by: Marshall J. Wilks <mjwilks@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/map28
-rw-r--r--src/include/vector8
2 files changed, 35 insertions, 1 deletions
diff --git a/src/include/map b/src/include/map
index ddfa17ea7..75e710163 100644
--- a/src/include/map
+++ b/src/include/map
@@ -473,6 +473,34 @@ namespace std
equal_range( const key_type& k) const
{ return submap::equal_range(k); }
};
+
+ /**
+ * @brief Map equality comparison.
+ * @param lhs A map.
+ * @param rhs A map of the same type as lhs.
+ * @return True iff the size and elements of the maps are equal.
+ *
+ * This is an equivalence relation. It is linear in the size of the
+ * maps. Maps are considered equivalent if their sizes are equal,
+ * and if corresponding elements compare equal.
+ */
+ template <typename _K, typename _T, typename _C>
+ inline bool operator==(const map<_K,_T,_C>& lhs,
+ const map<_K,_T,_C>& rhs)
+ {
+ return (lhs.size() == rhs.size()) &&
+ (std::equal(lhs.begin(), lhs.end(), rhs.begin()));
+ }
+
+ /**
+ * @brief Map inequality comparison. See operator==
+ */
+ template <typename _K, typename _T, typename _C>
+ inline bool operator!=(const map<_K,_T,_C>& lhs,
+ const map<_K,_T,_C>& rhs)
+ {
+ return !(lhs == rhs);
+ }
};
#endif
diff --git a/src/include/vector b/src/include/vector
index ac502a047..198d086cb 100644
--- a/src/include/vector
+++ b/src/include/vector
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2011,2016 */
+/* Contributors Listed Below - COPYRIGHT 2011,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -730,6 +730,12 @@ namespace std
return true;
}
+ template <class T, class U>
+ bool operator!=(const vector<T>& l, const vector<U>& r)
+ {
+ return !(l == r);
+ }
+
}; // end namespace std
// ------------------------------------------------------------------------------------------------
OpenPOWER on IntegriCloud