diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/map | 28 | ||||
-rw-r--r-- | src/include/vector | 8 |
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 // ------------------------------------------------------------------------------------------------ |