From 171a395a0a0182971d7e0135098c39cc9ab60b48 Mon Sep 17 00:00:00 2001 From: paolo Date: Fri, 3 Jun 2005 17:07:48 +0000 Subject: 2005-06-03 Paolo Carlini PR libstdc++/21770 * include/bits/stl_deque.h: Add concept-check. In class _Deque_base rebind _Alloc to _Tp_alloc_type, change _Deque_impl to inherit from the latter and add _M_get_Tp_allocator() which returns it. Use everywhere _M_get_Tp_allocator() instead of get_allocator(). * include/bits/deque.tcc: Likewise, use _M_get_Tp_allocator(). * include/bits/stl_list.h: Add concept-check. In class _List_base rebind _Alloc to _Tp_alloc_type and add _M_get_Tp_allocator(), which returns the allocator (of type _Node_alloc_type) converted to _Tp_alloc_type. Use everywhere _M_get_Tp_allocator() instead of get_allocator(). * include/bits/list.tcc: Likewise, use _M_get_Tp_allocator(). * include/bits/stl_vector.h: Add concept-check. In class _Vector_base rebind _Alloc to _Tp_alloc_type, change _Vector_impl to inherit from the latter and add _M_get_Tp_allocator() which returns it. Use everywhere _M_get_Tp_allocator() instead of get_allocator(). * include/bits/vector.tcc: Likewise, use _M_get_Tp_allocator(). * include/bits/stl_map.h: Add concept-check. Rebind _Alloc to _Pair_alloc_type and use it for _Rb_tree. * include/bits/stl_multimap.h: Likewise. * include/bits/stl_multiset.h: Add concept-check. Rebind _Alloc to _Key_alloc_type and use it for _Rb_tree. * include/bits/stl_set.h: Likewise. * include/bits/basic_string.h: Rebind _Alloc to _CharT_alloc_type and use it for the allocator typedefs. * testsuite/21_strings/basic_string/1.cc: New. * testsuite/23_containers/deque/explicit_instantiation.cc: Move to... * testsuite/23_containers/deque/explicit_instantiation/1.cc: ... here. * testsuite/23_containers/deque/explicit_instantiation/3.cc: New. * testsuite/23_containers/list/explicit_instantiation.cc: Move to... * testsuite/23_containers/list/explicit_instantiation/1.cc: ... here. * testsuite/23_containers/list/explicit_instantiation/3.cc: New. * testsuite/23_containers/map/explicit_instantiation.cc: Move to... * testsuite/23_containers/map/explicit_instantiation/1.cc: ... here. * testsuite/23_containers/map/explicit_instantiation/3.cc: New. * testsuite/23_containers/multimap/explicit_instantiation.cc: Move to... * testsuite/23_containers/multimap/explicit_instantiation/1.cc: .. here. * testsuite/23_containers/multimap/explicit_instantiation/3.cc: New. * testsuite/23_containers/multiset/explicit_instantiation.cc: Move to... * testsuite/23_containers/multiset/explicit_instantiation/1.cc: .. here. * testsuite/23_containers/multiset/explicit_instantiation/3.cc: New. * testsuite/23_containers/set/explicit_instantiation.cc: Move to... * testsuite/23_containers/set/explicit_instantiation/1.cc: .. here. * testsuite/23_containers/set/explicit_instantiation/3.cc: New. * testsuite/23_containers/vector/explicit_instantiation.cc: Move to... * testsuite/23_containers/vector/explicit_instantiation/1.cc: ... here. * testsuite/23_containers/vector/explicit_instantiation/3.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100546 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/include/bits/stl_set.h | 78 ++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 36 deletions(-) (limited to 'libstdc++-v3/include/bits/stl_set.h') diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index 1a15d1172c8..c76e55475c6 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -72,13 +72,13 @@ namespace _GLIBCXX_STD template inline bool - operator==(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y); + operator==(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y); template inline bool - operator<(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y); + operator<(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y); /** * @brief A standard container made up of unique keys, which can be @@ -107,9 +107,11 @@ namespace _GLIBCXX_STD class set { // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; __glibcxx_class_requires(_Key, _SGIAssignableConcept) __glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept) + __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept) public: // typedefs: @@ -119,29 +121,32 @@ namespace _GLIBCXX_STD typedef _Key value_type; typedef _Compare key_compare; typedef _Compare value_compare; + typedef _Alloc allocator_type; //@} private: - typedef _Rb_tree, key_compare, _Alloc> _Rep_type; + typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type; + + typedef _Rb_tree, + key_compare, _Key_alloc_type> _Rep_type; _Rep_type _M_t; // red-black tree representing set + public: //@{ /// Iterator-related typedefs. - typedef typename _Alloc::pointer pointer; - typedef typename _Alloc::const_pointer const_pointer; - typedef typename _Alloc::reference reference; - typedef typename _Alloc::const_reference const_reference; + typedef typename _Key_alloc_type::pointer pointer; + typedef typename _Key_alloc_type::const_pointer const_pointer; + typedef typename _Key_alloc_type::reference reference; + typedef typename _Key_alloc_type::const_reference const_reference; // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 103. set::iterator is required to be modifiable, // but this allows modification of keys. - typedef typename _Rep_type::const_iterator iterator; - typedef typename _Rep_type::const_iterator const_iterator; - typedef typename _Rep_type::const_reverse_iterator reverse_iterator; - typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; - typedef typename _Rep_type::size_type size_type; - typedef typename _Rep_type::difference_type difference_type; - typedef typename _Rep_type::allocator_type allocator_type; + typedef typename _Rep_type::const_iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::const_reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; //@} // allocation/deallocation @@ -155,8 +160,9 @@ namespace _GLIBCXX_STD * @param comp Comparator to use. * @param a Allocator to use. */ - explicit set(const _Compare& __comp, - const allocator_type& __a = allocator_type()) + explicit + set(const _Compare& __comp, + const allocator_type& __a = allocator_type()) : _M_t(__comp, __a) {} /** @@ -503,22 +509,22 @@ namespace _GLIBCXX_STD * * This function probably only makes sense for multisets. */ - std::pair + std::pair equal_range(const key_type& __x) { return _M_t.equal_range(__x); } - std::pair + std::pair equal_range(const key_type& __x) const { return _M_t.equal_range(__x); } //@} template friend bool - operator== (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); + operator== (const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); template friend bool - operator< (const set<_K1,_C1,_A1>&, const set<_K1,_C1,_A1>&); + operator< (const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); }; @@ -534,8 +540,8 @@ namespace _GLIBCXX_STD */ template inline bool - operator==(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator==(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return __x._M_t == __y._M_t; } /** @@ -551,42 +557,42 @@ namespace _GLIBCXX_STD */ template inline bool - operator<(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator<(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return __x._M_t < __y._M_t; } /// Returns !(x == y). template inline bool - operator!=(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator!=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return !(__x == __y); } /// Returns y < x. template inline bool - operator>(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator>(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return __y < __x; } /// Returns !(y < x) template inline bool - operator<=(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator<=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return !(__y < __x); } /// Returns !(x < y) template inline bool - operator>=(const set<_Key,_Compare,_Alloc>& __x, - const set<_Key,_Compare,_Alloc>& __y) + operator>=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) { return !(__x < __y); } /// See std::set::swap(). template inline void - swap(set<_Key,_Compare,_Alloc>& __x, set<_Key,_Compare,_Alloc>& __y) + swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y) { __x.swap(__y); } } // namespace std -- cgit v1.2.1