diff options
author | Martin Jambor <mjambor@suse.cz> | 2010-03-28 17:34:49 +0000 |
---|---|---|
committer | Martin Jambor <mjambor@suse.cz> | 2010-03-28 17:34:49 +0000 |
commit | 5f6b98384303d586c1190ec64d678a8721aac461 (patch) | |
tree | de208675ede67b2b66c0bc87b2612782248875d2 /libstdc++-v3 | |
parent | d8d7c681e2dfefa63ebd0ee7826e08d19b8cef9e (diff) |
Marge from trunk, revisions:
157643, 157645-157646, 157648-157652, 157654-157655, 157658,
157660-157665, 157667-157669, 157671, 157673-157677, 157681,
157688-157690, 157693, 157697-157 698, 157701-157707, 157709,
157713, 157715-157717, 157720-157721, 157723, 157728,
157730-157732, 157735-157738, 157741, 157743, 157745-157748
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/pretty-ipa@157785 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
24 files changed, 1252 insertions, 83 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index dac1b8ef5cc..5bd9f95f604 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,54 @@ +2010-03-25 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/unordered_map.h (operator==, operator!=): Add per N3068. + * include/bits/unordered_set.h (operator==, operator!=): Likewise. + * include/debug/unordered_map (operator==, operator!=): Likewise. + * include/debug/unordered_set: Likewise. + * include/profile/unordered_map: Likewise. + * include/profile/unordered_set: Likewise. + * testsuite/23_containers/unordered_map/operators/1.cc: New. + * testsuite/23_containers/unordered_multimap/operators/1.cc: Likewise. + * testsuite/23_containers/unordered_multimap/operators/2.cc: Likewise. + * testsuite/23_containers/unordered_set/operators/1.cc: Likewise. + * testsuite/23_containers/unordered_multiset/operators/1.cc: Likewise. + +2010-03-25 John Lakos <jlakos@bloomberg.net> + Pablo Halpern <phalpern@halpernwightsoftware.com> + Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/hashtable_policy.h (struct _Equality_base): Add. + * include/bits/hashtable.h (_Hashtable<>): Derive from the latter. + +2010-03-23 Paolo Carlini <paolo.carlini@oracle.com> + + * testsuite/util/testsuite_tr1.h (NType, TType, SLType, PODType): Add. + * testsuite/20_util/is_trivial/value.cc: Adjust. + * testsuite/20_util/is_standard_layout/value.cc: Likewise. + * testsuite/20_util/is_pod/value.cc: Likewise. + +2010-03-23 Paolo Carlini <paolo.carlini@oracle.com> + + * testsuite/20_util/is_trivial/value.cc: New. + * testsuite/20_util/is_standard_layout/value.cc: Likewise. + * testsuite/20_util/is_pod/value.cc: Extend. + +2010-03-23 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/stl_algobase.h (lower_bound(_ForwardIterator, + _ForwardIterator, const _Tp&, _Compare)): Move... + * include/bits/stl_algo.h: ... here. + +2010-03-22 Johannes Singler <singler@kit.edu> + + * include/parallel/numeric (inner_product, partial_sum): + Precede subsequent call with _GLIBCXX_STD_P:: to avoid ambiguity + between __gnu_parallel:: and std:: + * include/parallel/algobase.h (equal): Likewise. + * include/parallel/algo.h (find_first_of, search_n, merge, nth_element, + partial_sort, max_element, min_element): Likewise. + * include/parallel/partial_sum.h (__parallel_partial_sum_linear): + Qualify accumulate call with __gnu_parallel::. + 2010-03-22 Paolo Carlini <paolo.carlini@oracle.com> * include/parallel/base.h (_PseudoSequence): Do not forward declare. diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index cd7553d5133..c7aceb19f8e 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -118,7 +118,15 @@ namespace std _RehashPolicy, __cache_hash_code, __constant_iterators, - __unique_keys> > + __unique_keys> >, + public __detail::_Equality_base<_ExtractKey, __unique_keys, + _Hashtable<_Key, _Value, _Allocator, + _ExtractKey, + _Equal, _H1, _H2, _Hash, + _RehashPolicy, + __cache_hash_code, + __constant_iterators, + __unique_keys> > { public: typedef _Allocator allocator_type; diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index 142c57fd9a6..6e6a8fb0177 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -484,24 +484,24 @@ namespace __detail return std::make_pair(false, 0); } - // Base classes for std::tr1::_Hashtable. We define these base - // classes because in some cases we want to do different things - // depending on the value of a policy class. In some cases the - // policy class affects which member functions and nested typedefs - // are defined; we handle that by specializing base class templates. - // Several of the base class templates need to access other members - // of class template _Hashtable, so we use the "curiously recurring - // template pattern" for them. - - // class template _Map_base. If the hashtable has a value type of the - // form pair<T1, T2> and a key extraction policy that returns the + // Base classes for std::_Hashtable. We define these base classes + // because in some cases we want to do different things depending + // on the value of a policy class. In some cases the policy class + // affects which member functions and nested typedefs are defined; + // we handle that by specializing base class templates. Several of + // the base class templates need to access other members of class + // template _Hashtable, so we use the "curiously recurring template + // pattern" for them. + + // class template _Map_base. If the hashtable has a value type of + // the form pair<T1, T2> and a key extraction policy that returns the // first part of the pair, the hashtable gets a mapped_type typedef. // If it satisfies those criteria and also has unique keys, then it // also gets an operator[]. template<typename _Key, typename _Value, typename _Ex, bool __unique, typename _Hashtable> struct _Map_base { }; - + template<typename _Key, typename _Pair, typename _Hashtable> struct _Map_base<_Key, _Pair, std::_Select1st<_Pair>, false, _Hashtable> { @@ -512,7 +512,7 @@ namespace __detail struct _Map_base<_Key, _Pair, std::_Select1st<_Pair>, true, _Hashtable> { typedef typename _Pair::second_type mapped_type; - + mapped_type& operator[](const _Key& __k); @@ -832,6 +832,127 @@ namespace __detail _H1 _M_h1; _H2 _M_h2; }; + + + // Class template _Equality_base. This is for implementing equality + // comparison for unordered containers, per N3068, by John Lakos and + // Pablo Halpern. Algorithmically, we follow closely the reference + // implementations therein. + template<typename _ExtractKey, bool __unique_keys, + typename _Hashtable> + struct _Equality_base; + + template<typename _ExtractKey, typename _Hashtable> + struct _Equality_base<_ExtractKey, true, _Hashtable> + { + bool _M_equal(const _Hashtable&) const; + }; + + template<typename _ExtractKey, typename _Hashtable> + bool + _Equality_base<_ExtractKey, true, _Hashtable>:: + _M_equal(const _Hashtable& __other) const + { + const _Hashtable* __this = static_cast<const _Hashtable*>(this); + + if (__this->size() != __other.size()) + return false; + + for (auto __itx = __this->begin(); __itx != __this->end(); ++__itx) + { + const auto __ity = __other.find(_ExtractKey()(*__itx)); + if (__ity == __other.end() || *__ity != *__itx) + return false; + } + return true; + } + + template<typename _ExtractKey, typename _Hashtable> + struct _Equality_base<_ExtractKey, false, _Hashtable> + { + bool _M_equal(const _Hashtable&) const; + + private: + template<typename _Uiterator> + static bool + _S_is_permutation(_Uiterator, _Uiterator, _Uiterator); + }; + + // See std::is_permutation in N3068. + template<typename _ExtractKey, typename _Hashtable> + template<typename _Uiterator> + bool + _Equality_base<_ExtractKey, false, _Hashtable>:: + _S_is_permutation(_Uiterator __first1, _Uiterator __last1, + _Uiterator __first2) + { + for (; __first1 != __last1; ++__first1, ++__first2) + if (!(*__first1 == *__first2)) + break; + + if (__first1 == __last1) + return true; + + _Uiterator __last2 = __first2; + std::advance(__last2, std::distance(__first1, __last1)); + + for (_Uiterator __it1 = __first1; __it1 != __last1; ++__it1) + { + _Uiterator __tmp = __first1; + while (__tmp != __it1 && !(*__tmp == *__it1)) + ++__tmp; + + // We've seen this one before. + if (__tmp != __it1) + continue; + + std::ptrdiff_t __n2 = 0; + for (__tmp = __first2; __tmp != __last2; ++__tmp) + if (*__tmp == *__it1) + ++__n2; + + if (!__n2) + return false; + + std::ptrdiff_t __n1 = 0; + for (__tmp = __it1; __tmp != __last1; ++__tmp) + if (*__tmp == *__it1) + ++__n1; + + if (__n1 != __n2) + return false; + } + return true; + } + + template<typename _ExtractKey, typename _Hashtable> + bool + _Equality_base<_ExtractKey, false, _Hashtable>:: + _M_equal(const _Hashtable& __other) const + { + const _Hashtable* __this = static_cast<const _Hashtable*>(this); + + if (__this->size() != __other.size()) + return false; + + for (auto __itx = __this->begin(); __itx != __this->end();) + { + const auto __xrange = __this->equal_range(_ExtractKey()(*__itx)); + const auto __yrange = __other.equal_range(_ExtractKey()(*__itx)); + + if (std::distance(__xrange.first, __xrange.second) + != std::distance(__yrange.first, __yrange.second)) + return false; + + if (!_S_is_permutation(__xrange.first, + __xrange.second, + __yrange.first)) + return false; + + __itx = __xrange.second; + } + return true; + } } // namespace __detail } diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 126305a00f8..5b4991e33b6 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -2370,6 +2370,60 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // lower_bound moved to stl_algobase.h /** + * @brief Finds the first position in which @a val could be inserted + * without changing the ordering. + * @ingroup binary_search_algorithms + * @param first An iterator. + * @param last Another iterator. + * @param val The search term. + * @param comp A functor to use for comparisons. + * @return An iterator pointing to the first element <em>not less + * than</em> @a val, or end() if every element is less + * than @a val. + * @ingroup binary_search_algorithms + * + * The comparison function should have the same effects on ordering as + * the function used for the initial sort. + */ + template<typename _ForwardIterator, typename _Tp, typename _Compare> + _ForwardIterator + lower_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + typedef typename iterator_traits<_ForwardIterator>::difference_type + _DistanceType; + + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _ValueType, _Tp>) + __glibcxx_requires_partitioned_lower_pred(__first, __last, + __val, __comp); + + _DistanceType __len = std::distance(__first, __last); + _DistanceType __half; + _ForwardIterator __middle; + + while (__len > 0) + { + __half = __len >> 1; + __middle = __first; + std::advance(__middle, __half); + if (__comp(*__middle, __val)) + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else + __len = __half; + } + return __first; + } + + /** * @brief Finds the last position in which @a val could be inserted * without changing the ordering. * @ingroup binary_search_algorithms diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 1756966a5a1..e92540431de 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -985,60 +985,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) return __first; } - /** - * @brief Finds the first position in which @a val could be inserted - * without changing the ordering. - * @ingroup binary_search_algorithms - * @param first An iterator. - * @param last Another iterator. - * @param val The search term. - * @param comp A functor to use for comparisons. - * @return An iterator pointing to the first element <em>not less - * than</em> @a val, or end() if every element is less - * than @a val. - * @ingroup binary_search_algorithms - * - * The comparison function should have the same effects on ordering as - * the function used for the initial sort. - */ - template<typename _ForwardIterator, typename _Tp, typename _Compare> - _ForwardIterator - lower_bound(_ForwardIterator __first, _ForwardIterator __last, - const _Tp& __val, _Compare __comp) - { - typedef typename iterator_traits<_ForwardIterator>::value_type - _ValueType; - typedef typename iterator_traits<_ForwardIterator>::difference_type - _DistanceType; - - // concept requirements - __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) - __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, - _ValueType, _Tp>) - __glibcxx_requires_partitioned_lower_pred(__first, __last, - __val, __comp); - - _DistanceType __len = std::distance(__first, __last); - _DistanceType __half; - _ForwardIterator __middle; - - while (__len > 0) - { - __half = __len >> 1; - __middle = __first; - std::advance(__middle, __half); - if (__comp(*__middle, __val)) - { - __first = __middle; - ++__first; - __len = __len - __half - 1; - } - else - __len = __half; - } - return __first; - } - /// This is a helper function for the sort routines and for random.tcc. // Precondition: __n > 0. template<typename _Size> diff --git a/libstdc++-v3/include/bits/unordered_map.h b/libstdc++-v3/include/bits/unordered_map.h index 77236d3aca6..74998ff7725 100644 --- a/libstdc++-v3/include/bits/unordered_map.h +++ b/libstdc++-v3/include/bits/unordered_map.h @@ -159,6 +159,41 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _Alloc, __cache_hash_code>& __y) { __x.swap(__y); } + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, + bool __cache_hash_code> + inline bool + operator==(const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc, + __cache_hash_code>& __x, + const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc, + __cache_hash_code>& __y) + { return __x._M_equal(__y); } + + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, + bool __cache_hash_code> + inline bool + operator!=(const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc, + __cache_hash_code>& __x, + const __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc, + __cache_hash_code>& __y) + { return !(__x == __y); } + + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, + bool __cache_hash_code> + inline bool + operator==(const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc, + __cache_hash_code>& __x, + const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc, + __cache_hash_code>& __y) + { return __x._M_equal(__y); } + + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, + bool __cache_hash_code> + inline bool + operator!=(const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc, + __cache_hash_code>& __x, + const __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc, + __cache_hash_code>& __y) + { return !(__x == __y); } /** * @brief A standard container composed of unique keys (containing @@ -335,6 +370,30 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> + inline bool + operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> + inline bool + operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> + inline bool + operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> + inline bool + operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + _GLIBCXX_END_NESTED_NAMESPACE #endif /* _UNORDERED_MAP_H */ diff --git a/libstdc++-v3/include/bits/unordered_set.h b/libstdc++-v3/include/bits/unordered_set.h index a20fbf4b05d..50dee215e16 100644 --- a/libstdc++-v3/include/bits/unordered_set.h +++ b/libstdc++-v3/include/bits/unordered_set.h @@ -155,6 +155,41 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _Alloc, __cache_hash_code>& __y) { __x.swap(__y); } + template<class _Value, class _Hash, class _Pred, class _Alloc, + bool __cache_hash_code> + inline bool + operator==(const __unordered_set<_Value, _Hash, _Pred, _Alloc, + __cache_hash_code>& __x, + const __unordered_set<_Value, _Hash, _Pred, _Alloc, + __cache_hash_code>& __y) + { return __x._M_equal(__y); } + + template<class _Value, class _Hash, class _Pred, class _Alloc, + bool __cache_hash_code> + inline bool + operator!=(const __unordered_set<_Value, _Hash, _Pred, _Alloc, + __cache_hash_code>& __x, + const __unordered_set<_Value, _Hash, _Pred, _Alloc, + __cache_hash_code>& __y) + { return !(__x == __y); } + + template<class _Value, class _Hash, class _Pred, class _Alloc, + bool __cache_hash_code> + inline bool + operator==(const __unordered_multiset<_Value, _Hash, _Pred, _Alloc, + __cache_hash_code>& __x, + const __unordered_multiset<_Value, _Hash, _Pred, _Alloc, + __cache_hash_code>& __y) + { return __x._M_equal(__y); } + + template<class _Value, class _Hash, class _Pred, class _Alloc, + bool __cache_hash_code> + inline bool + operator!=(const __unordered_multiset<_Value, _Hash, _Pred, _Alloc, + __cache_hash_code>& __x, + const __unordered_multiset<_Value, _Hash, _Pred, _Alloc, + __cache_hash_code>& __y) + { return !(__x == __y); } /** * @brief A standard container composed of unique keys (containing @@ -325,6 +360,30 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } + template<class _Value, class _Hash, class _Pred, class _Alloc> + inline bool + operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<class _Value, class _Hash, class _Pred, class _Alloc> + inline bool + operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + + template<class _Value, class _Hash, class _Pred, class _Alloc> + inline bool + operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<class _Value, class _Hash, class _Pred, class _Alloc> + inline bool + operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + _GLIBCXX_END_NESTED_NAMESPACE #endif /* _UNORDERED_SET_H */ diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map index a5e6174fe6a..6fef1e97057 100644 --- a/libstdc++-v3/include/debug/unordered_map +++ b/libstdc++-v3/include/debug/unordered_map @@ -287,6 +287,20 @@ namespace __debug unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + /// Class std::unordered_multimap with safety/checking/debug instrumentation. template<typename _Key, typename _Tp, @@ -524,6 +538,20 @@ namespace __debug unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + } // namespace __debug } // namespace std diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set index f8517184023..09329b00367 100644 --- a/libstdc++-v3/include/debug/unordered_set +++ b/libstdc++-v3/include/debug/unordered_set @@ -286,6 +286,18 @@ namespace __debug unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + /// Class std::unordered_multiset with safety/checking/debug instrumentation. template<typename _Value, @@ -521,6 +533,18 @@ namespace __debug unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + } // namespace __debug } // namespace std diff --git a/libstdc++-v3/include/parallel/algo.h b/libstdc++-v3/include/parallel/algo.h index aa87a48450a..cc2fc679bcf 100644 --- a/libstdc++-v3/include/parallel/algo.h +++ b/libstdc++-v3/include/parallel/algo.h @@ -292,8 +292,8 @@ namespace __parallel typedef typename _IIterTraits::value_type _IValueType; typedef typename iteratorf_traits::value_type _FValueType; - return find_first_of(__begin1, __end1, __begin2, __end2, __gnu_parallel:: - _EqualTo<_IValueType, _FValueType>()); + return _GLIBCXX_STD_P::find_first_of(__begin1, __end1, __begin2, __end2, + __gnu_parallel::_EqualTo<_IValueType, _FValueType>()); } // Sequential fallback @@ -1160,7 +1160,7 @@ namespace __parallel const _Tp& __val) { typedef typename iterator_traits<_FIterator>::value_type _ValueType; - return search_n(__begin, __end, __count, __val, + return _GLIBCXX_STD_P::search_n(__begin, __end, __count, __val, __gnu_parallel::_EqualTo<_ValueType, _Tp>()); } @@ -2086,8 +2086,8 @@ namespace __parallel typedef typename _Iterator1Traits::value_type _ValueType1; typedef typename _Iterator2Traits::value_type _ValueType2; - return merge(__begin1, __end1, __begin2, __end2, __result, - __gnu_parallel::_Less<_ValueType1, _ValueType2>()); + return _GLIBCXX_STD_P::merge(__begin1, __end1, __begin2, __end2, + __result, __gnu_parallel::_Less<_ValueType1, _ValueType2>()); } // Sequential fallback @@ -2128,7 +2128,8 @@ namespace __parallel { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; - nth_element(__begin, __nth, __end, std::less<_ValueType>()); + _GLIBCXX_STD_P::nth_element(__begin, __nth, __end, + std::less<_ValueType>()); } // Sequential fallback @@ -2170,7 +2171,8 @@ namespace __parallel { typedef iterator_traits<_RAIter> _TraitsType; typedef typename _TraitsType::value_type _ValueType; - partial_sort(__begin, __middle, __end, std::less<_ValueType>()); + _GLIBCXX_STD_P::partial_sort(__begin, __middle, __end, + std::less<_ValueType>()); } // Sequential fallback @@ -2239,7 +2241,8 @@ namespace __parallel max_element(_FIterator __begin, _FIterator __end) { typedef typename iterator_traits<_FIterator>::value_type _ValueType; - return max_element(__begin, __end, std::less<_ValueType>()); + return _GLIBCXX_STD_P::max_element(__begin, __end, + std::less<_ValueType>()); } // Public interface @@ -2330,7 +2333,8 @@ namespace __parallel min_element(_FIterator __begin, _FIterator __end) { typedef typename iterator_traits<_FIterator>::value_type _ValueType; - return min_element(__begin, __end, std::less<_ValueType>()); + return _GLIBCXX_STD_P::min_element(__begin, __end, + std::less<_ValueType>()); } // Public interface diff --git a/libstdc++-v3/include/parallel/algobase.h b/libstdc++-v3/include/parallel/algobase.h index df1c58bedb6..9cc81bd2aaa 100644 --- a/libstdc++-v3/include/parallel/algobase.h +++ b/libstdc++-v3/include/parallel/algobase.h @@ -141,14 +141,20 @@ namespace __parallel template<typename _IIter1, typename _IIter2> inline bool equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2) - { return mismatch(__begin1, __end1, __begin2).first == __end1; } + { + return _GLIBCXX_STD_P::mismatch(__begin1, __end1, __begin2).first + == __end1; + } // Public interface template<typename _IIter1, typename _IIter2, typename _Predicate> inline bool equal(_IIter1 __begin1, _IIter1 __end1, _IIter2 __begin2, _Predicate __pred) - { return mismatch(__begin1, __end1, __begin2, __pred).first == __end1; } + { + return _GLIBCXX_STD_P::mismatch(__begin1, __end1, __begin2, __pred).first + == __end1; + } // Sequential fallback template<typename _IIter1, typename _IIter2> diff --git a/libstdc++-v3/include/parallel/numeric b/libstdc++-v3/include/parallel/numeric index 76916ff3ecb..7ba44d21e33 100644 --- a/libstdc++-v3/include/parallel/numeric +++ b/libstdc++-v3/include/parallel/numeric @@ -283,7 +283,7 @@ namespace __parallel typedef typename __gnu_parallel::_Multiplies<_ValueType1, _ValueType2>::result_type _MultipliesResultType; - return inner_product(__first1, __last1, __first2, __init, + return _GLIBCXX_STD_P::inner_product(__first1, __last1, __first2, __init, __gnu_parallel::_Plus<_Tp, _MultipliesResultType>(), __gnu_parallel:: _Multiplies<_ValueType1, _ValueType2>(), @@ -303,7 +303,7 @@ namespace __parallel typedef typename __gnu_parallel::_Multiplies<_ValueType1, _ValueType2>::result_type _MultipliesResultType; - return inner_product(__first1, __last1, __first2, __init, + return _GLIBCXX_STD_P::inner_product(__first1, __last1, __first2, __init, __gnu_parallel::_Plus<_Tp, _MultipliesResultType>(), __gnu_parallel:: _Multiplies<_ValueType1, _ValueType2>()); @@ -359,7 +359,8 @@ namespace __parallel partial_sum(_IIter __begin, _IIter __end, _OutputIterator __result) { typedef typename iterator_traits<_IIter>::value_type _ValueType; - return partial_sum(__begin, __end, __result, std::plus<_ValueType>()); + return _GLIBCXX_STD_P::partial_sum(__begin, __end, + __result, std::plus<_ValueType>()); } // Public interface diff --git a/libstdc++-v3/include/parallel/partial_sum.h b/libstdc++-v3/include/parallel/partial_sum.h index 487fd6dd666..966d9db0572 100644 --- a/libstdc++-v3/include/parallel/partial_sum.h +++ b/libstdc++-v3/include/parallel/partial_sum.h @@ -158,7 +158,8 @@ namespace __gnu_parallel else { ::new(&(__sums[__iam])) - _ValueType(std::accumulate(__begin + __borders[__iam] + 1, + _ValueType(__gnu_parallel::accumulate( + __begin + __borders[__iam] + 1, __begin + __borders[__iam + 1], *(__begin + __borders[__iam]), __bin_op, diff --git a/libstdc++-v3/include/profile/unordered_map b/libstdc++-v3/include/profile/unordered_map index b90d58b5ab6..b9e67873d95 100644 --- a/libstdc++-v3/include/profile/unordered_map +++ b/libstdc++-v3/include/profile/unordered_map @@ -272,6 +272,20 @@ namespace __profile unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + #undef _GLIBCXX_BASE #undef _GLIBCXX_STD_BASE #define _GLIBCXX_BASE unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> @@ -482,6 +496,20 @@ namespace __profile unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + } // namespace __profile } // namespace std diff --git a/libstdc++-v3/include/profile/unordered_set b/libstdc++-v3/include/profile/unordered_set index 128cf602b45..6dcdc837398 100644 --- a/libstdc++-v3/include/profile/unordered_set +++ b/libstdc++-v3/include/profile/unordered_set @@ -262,6 +262,18 @@ namespace __profile unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + #undef _GLIBCXX_BASE #undef _GLIBCXX_STD_BASE #define _GLIBCXX_STD_BASE _GLIBCXX_STD_PR::_GLIBCXX_BASE @@ -474,6 +486,18 @@ namespace __profile unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) { __x.swap(__y); } + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_equal(__y); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline bool + operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } + } // namespace __profile } // namespace std diff --git a/libstdc++-v3/testsuite/20_util/is_pod/value.cc b/libstdc++-v3/testsuite/20_util/is_pod/value.cc index 055a41c5825..e4926d5a660 100644 --- a/libstdc++-v3/testsuite/20_util/is_pod/value.cc +++ b/libstdc++-v3/testsuite/20_util/is_pod/value.cc @@ -43,8 +43,12 @@ void test01() VERIFY( (test_category<is_pod, int (ClassType::*[2][3])>(true)) ); VERIFY( (test_category<is_pod, int (ClassType::*[][2][3]) (int)>(true)) ); VERIFY( (test_category<is_pod, ClassType>(true)) ); + VERIFY( (test_category<is_pod, PODType>(true)) ); VERIFY( (test_category<is_pod, void>(false)) ); + VERIFY( (test_category<is_pod, NType>(false)) ); + VERIFY( (test_category<is_pod, TType>(false)) ); + VERIFY( (test_category<is_pod, SLType>(false)) ); } int main() diff --git a/libstdc++-v3/testsuite/20_util/is_standard_layout/value.cc b/libstdc++-v3/testsuite/20_util/is_standard_layout/value.cc new file mode 100644 index 00000000000..7ef8609061c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_standard_layout/value.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-23 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_standard_layout; + using namespace __gnu_test; + + VERIFY( (test_category<is_standard_layout, SLType>(true)) ); + VERIFY( (test_category<is_standard_layout, PODType>(true)) ); + + VERIFY( (test_category<is_standard_layout, NType>(false)) ); + VERIFY( (test_category<is_standard_layout, TType>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_trivial/value.cc b/libstdc++-v3/testsuite/20_util/is_trivial/value.cc new file mode 100644 index 00000000000..e6ff8fac502 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_trivial/value.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// 2010-03-23 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_trivial; + using namespace __gnu_test; + + VERIFY( (test_category<is_trivial, TType>(true)) ); + VERIFY( (test_category<is_trivial, PODType>(true)) ); + + VERIFY( (test_category<is_trivial, NType>(false)) ); + VERIFY( (test_category<is_trivial, SLType>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/operators/1.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/operators/1.cc new file mode 100644 index 00000000000..f5e68dea79d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/operators/1.cc @@ -0,0 +1,169 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-03-25 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::pair<const int, int> Pair; + std::unordered_map<int, int> um1, um2; + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(2, -1)); + um2.insert(Pair(2, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(3, -3)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um2.insert(Pair(3, -3)); + VERIFY( (um1 == um2) ); + VERIFY( !(um1 != um2) ); + + um2.clear(); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.clear(); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(2, -2)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(2, -2)); + um2.insert(Pair(1, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(3, -3)); + um2.insert(Pair(4, -4)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(4, -4)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um2.insert(Pair(3, -3)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(4, -4)); + um2.insert(Pair(4, -4)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.clear(); + um2.clear(); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -2)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.clear(); + um2.clear(); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(2, -2)); + um2.insert(Pair(2, -3)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(2, -3)); + um2.insert(Pair(2, -2)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.clear(); + um2.clear(); + VERIFY( um1 == um2 ); + VERIFY( !(um1 != um2) ); + + um1.insert(Pair(2, -2)); + um2.insert(Pair(2, -3)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(2, -3)); + um2.insert(Pair(2, -2)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -1)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + um1.insert(Pair(1, -1)); + um2.insert(Pair(1, -2)); + VERIFY( um1 != um2 ); + VERIFY( !(um1 == um2) ); + + const std::unordered_map<int, int> cum1(um1), cum2(um2); + VERIFY( cum1 != cum2 ); + VERIFY( !(cum1 == cum2) ); + VERIFY( cum1 != um2 ); + VERIFY( !(um1 == cum2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/1.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/1.cc new file mode 100644 index 00000000000..f6e21f8b845 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/1.cc @@ -0,0 +1,192 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-03-25 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::pair<const int, int> Pair; + std::unordered_multimap<int, int> umm1, umm2; + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(2, -1)); + umm2.insert(Pair(2, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(3, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm2.insert(Pair(3, -3)); + VERIFY( (umm1 == umm2) ); + VERIFY( !(umm1 != umm2) ); + + umm2.clear(); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.clear(); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(2, -2)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(2, -2)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(3, -3)); + umm2.insert(Pair(4, -4)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(4, -4)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm2.insert(Pair(3, -3)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(4, -4)); + umm2.insert(Pair(4, -4)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.clear(); + umm2.clear(); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -2)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.clear(); + umm2.clear(); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(2, -2)); + umm2.insert(Pair(2, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(2, -3)); + umm2.insert(Pair(2, -2)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.clear(); + umm2.clear(); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(2, -2)); + umm2.insert(Pair(2, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(2, -3)); + umm2.insert(Pair(2, -2)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + umm1.insert(Pair(1, -1)); + umm2.insert(Pair(1, -2)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(3, -3)); + umm2.insert(Pair(3, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(3, -4)); + umm2.insert(Pair(3, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(3, -3)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm1.insert(Pair(1, -2)); + umm2.insert(Pair(1, -1)); + VERIFY( umm1 != umm2 ); + VERIFY( !(umm1 == umm2) ); + + umm2.insert(Pair(3, -4)); + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + const std::unordered_multimap<int, int> cumm1(umm1), cumm2(umm2); + VERIFY( cumm1 == cumm2 ); + VERIFY( !(cumm1 != cumm2) ); + VERIFY( cumm1 == umm2 ); + VERIFY( !(umm1 != cumm2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/2.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/2.cc new file mode 100644 index 00000000000..1121dbc5200 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/operators/2.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-03-25 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <unordered_map> +#include <algorithm> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::pair<const int, int> Pair; + std::unordered_multimap<int, int> umm1, umm2; + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + + int second1[] = { -1, -2, -3, -4, -5 }; + int second2[] = { -1, -2, -3, -4, -5 }; + const unsigned size = sizeof(second1) / sizeof(int); + + for (unsigned perm1 = 0; perm1 < 120; ++perm1) + { + umm1.clear(); + std::next_permutation(second1, second1 + size); + for (unsigned i1 = 0; i1 < size; ++i1) + umm1.insert(Pair(0, second1[i1])); + + for (unsigned perm2 = 0; perm2 < 120; ++perm2) + { + umm2.clear(); + std::next_permutation(second2, second2 + size); + for (unsigned i2 = 0; i2 < size; ++i2) + umm2.insert(Pair(0, second2[i2])); + + VERIFY( umm1 == umm2 ); + VERIFY( !(umm1 != umm2) ); + } + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/operators/1.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/operators/1.cc new file mode 100644 index 00000000000..3e3b1c762fb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/operators/1.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-03-25 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_multiset<int> ums1, ums2; + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(1); + ums2.insert(1); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(2); + ums2.insert(2); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(1); + ums2.insert(1); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(3); + VERIFY( ums1 != ums2 ); + VERIFY( !(ums1 == ums2) ); + + ums2.insert(3); + VERIFY( (ums1 == ums2) ); + VERIFY( !(ums1 != ums2) ); + + ums2.clear(); + VERIFY( ums1 != ums2 ); + VERIFY( !(ums1 == ums2) ); + + ums1.clear(); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(1); + ums2.insert(2); + VERIFY( ums1 != ums2 ); + VERIFY( !(ums1 == ums2) ); + + ums1.insert(2); + ums2.insert(1); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(3); + ums2.insert(4); + VERIFY( ums1 != ums2 ); + VERIFY( !(ums1 == ums2) ); + + ums1.insert(4); + VERIFY( ums1 != ums2 ); + VERIFY( !(ums1 == ums2) ); + + ums2.insert(3); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(1); + ums2.insert(1); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + ums1.insert(4); + ums2.insert(4); + VERIFY( ums1 == ums2 ); + VERIFY( !(ums1 != ums2) ); + + const std::unordered_multiset<int> cums1(ums1), cums2(ums2); + VERIFY( cums1 == cums2 ); + VERIFY( !(cums1 != cums2) ); + VERIFY( cums1 == ums2 ); + VERIFY( !(ums1 != cums2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/operators/1.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/operators/1.cc new file mode 100644 index 00000000000..63e726d0473 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/operators/1.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-03-25 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unordered_set<int> us1, us2; + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(2); + us2.insert(2); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(3); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us2.insert(3); + VERIFY( (us1 == us2) ); + VERIFY( !(us1 != us2) ); + + us2.clear(); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us1.clear(); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(2); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us1.insert(2); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(3); + us2.insert(4); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us1.insert(4); + VERIFY( us1 != us2 ); + VERIFY( !(us1 == us2) ); + + us2.insert(3); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(1); + us2.insert(1); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + us1.insert(4); + us2.insert(4); + VERIFY( us1 == us2 ); + VERIFY( !(us1 != us2) ); + + const std::unordered_set<int> cus1(us1), cus2(us2); + VERIFY( cus1 == cus2 ); + VERIFY( !(cus1 != cus2) ); + VERIFY( cus1 == us2 ); + VERIFY( !(us1 != cus2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/util/testsuite_tr1.h b/libstdc++-v3/testsuite/util/testsuite_tr1.h index aecf56220e0..4f3e574ccc2 100644 --- a/libstdc++-v3/testsuite/util/testsuite_tr1.h +++ b/libstdc++-v3/testsuite/util/testsuite_tr1.h @@ -129,6 +129,33 @@ namespace __gnu_test explicit ExplicitClass(int&); }; + struct NType // neither trivial nor standard-layout + { + int i; + int j; + virtual ~NType(); + }; + + struct TType // trivial but not standard-layout + { + int i; + private: + int j; + }; + + struct SLType // standard-layout but not trivial + { + int i; + int j; + ~SLType(); + }; + + struct PODType // both trivial and standard-layout + { + int i; + int j; + }; + int truncate_float(float x) { return (int)x; } long truncate_double(double x) { return (long)x; } |