138fd1498Szrj // Debugging set implementation -*- C++ -*- 238fd1498Szrj 338fd1498Szrj // Copyright (C) 2003-2018 Free Software Foundation, Inc. 438fd1498Szrj // 538fd1498Szrj // This file is part of the GNU ISO C++ Library. This library is free 638fd1498Szrj // software; you can redistribute it and/or modify it under the 738fd1498Szrj // terms of the GNU General Public License as published by the 838fd1498Szrj // Free Software Foundation; either version 3, or (at your option) 938fd1498Szrj // any later version. 1038fd1498Szrj 1138fd1498Szrj // This library is distributed in the hope that it will be useful, 1238fd1498Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of 1338fd1498Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1438fd1498Szrj // GNU General Public License for more details. 1538fd1498Szrj 1638fd1498Szrj // Under Section 7 of GPL version 3, you are granted additional 1738fd1498Szrj // permissions described in the GCC Runtime Library Exception, version 1838fd1498Szrj // 3.1, as published by the Free Software Foundation. 1938fd1498Szrj 2038fd1498Szrj // You should have received a copy of the GNU General Public License and 2138fd1498Szrj // a copy of the GCC Runtime Library Exception along with this program; 2238fd1498Szrj // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 2338fd1498Szrj // <http://www.gnu.org/licenses/>. 2438fd1498Szrj 2538fd1498Szrj /** @file debug/set.h 2638fd1498Szrj * This file is a GNU debug extension to the Standard C++ Library. 2738fd1498Szrj */ 2838fd1498Szrj 2938fd1498Szrj #ifndef _GLIBCXX_DEBUG_SET_H 3038fd1498Szrj #define _GLIBCXX_DEBUG_SET_H 1 3138fd1498Szrj 3238fd1498Szrj #include <debug/safe_sequence.h> 3338fd1498Szrj #include <debug/safe_container.h> 3438fd1498Szrj #include <debug/safe_iterator.h> 3538fd1498Szrj #include <utility> 3638fd1498Szrj 3738fd1498Szrj namespace std _GLIBCXX_VISIBILITY(default) 3838fd1498Szrj { 3938fd1498Szrj namespace __debug 4038fd1498Szrj { 4138fd1498Szrj /// Class std::set with safety/checking/debug instrumentation. 4238fd1498Szrj template<typename _Key, typename _Compare = std::less<_Key>, 4338fd1498Szrj typename _Allocator = std::allocator<_Key> > 4438fd1498Szrj class set 4538fd1498Szrj : public __gnu_debug::_Safe_container< 4638fd1498Szrj set<_Key, _Compare, _Allocator>, _Allocator, 4738fd1498Szrj __gnu_debug::_Safe_node_sequence>, 4838fd1498Szrj public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator> 4938fd1498Szrj { 5038fd1498Szrj typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base; 5138fd1498Szrj typedef __gnu_debug::_Safe_container< 5238fd1498Szrj set, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe; 5338fd1498Szrj 5438fd1498Szrj typedef typename _Base::const_iterator _Base_const_iterator; 5538fd1498Szrj typedef typename _Base::iterator _Base_iterator; 5638fd1498Szrj typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal; 5738fd1498Szrj 5838fd1498Szrj public: 5938fd1498Szrj // types: 6038fd1498Szrj typedef _Key key_type; 6138fd1498Szrj typedef _Key value_type; 6238fd1498Szrj typedef _Compare key_compare; 6338fd1498Szrj typedef _Compare value_compare; 6438fd1498Szrj typedef _Allocator allocator_type; 6538fd1498Szrj typedef typename _Base::reference reference; 6638fd1498Szrj typedef typename _Base::const_reference const_reference; 6738fd1498Szrj 6838fd1498Szrj typedef __gnu_debug::_Safe_iterator<_Base_iterator, set> 6938fd1498Szrj iterator; 7038fd1498Szrj typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, set> 7138fd1498Szrj const_iterator; 7238fd1498Szrj 7338fd1498Szrj typedef typename _Base::size_type size_type; 7438fd1498Szrj typedef typename _Base::difference_type difference_type; 7538fd1498Szrj typedef typename _Base::pointer pointer; 7638fd1498Szrj typedef typename _Base::const_pointer const_pointer; 7738fd1498Szrj typedef std::reverse_iterator<iterator> reverse_iterator; 7838fd1498Szrj typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 7938fd1498Szrj 8038fd1498Szrj // 23.3.3.1 construct/copy/destroy: 8138fd1498Szrj 8238fd1498Szrj #if __cplusplus < 201103L 8338fd1498Szrj set() : _Base() { } 8438fd1498Szrj 8538fd1498Szrj set(const set& __x) 8638fd1498Szrj : _Base(__x) { } 8738fd1498Szrj 8838fd1498Szrj ~set() { } 8938fd1498Szrj #else 9038fd1498Szrj set() = default; 9138fd1498Szrj set(const set&) = default; 9238fd1498Szrj set(set&&) = default; 9338fd1498Szrj 9438fd1498Szrj set(initializer_list<value_type> __l, 9538fd1498Szrj const _Compare& __comp = _Compare(), 9638fd1498Szrj const allocator_type& __a = allocator_type()) 9738fd1498Szrj : _Base(__l, __comp, __a) { } 9838fd1498Szrj 9938fd1498Szrj explicit 10038fd1498Szrj set(const allocator_type& __a) 10138fd1498Szrj : _Base(__a) { } 10238fd1498Szrj 10338fd1498Szrj set(const set& __x, const allocator_type& __a) 10438fd1498Szrj : _Base(__x, __a) { } 10538fd1498Szrj 10638fd1498Szrj set(set&& __x, const allocator_type& __a) 107*58e805e6Szrj noexcept( noexcept(_Base(std::move(__x._M_base()), __a)) ) 10838fd1498Szrj : _Safe(std::move(__x._M_safe()), __a), 10938fd1498Szrj _Base(std::move(__x._M_base()), __a) { } 11038fd1498Szrj 11138fd1498Szrj set(initializer_list<value_type> __l, const allocator_type& __a) 11238fd1498Szrj : _Base(__l, __a) { } 11338fd1498Szrj 11438fd1498Szrj template<typename _InputIterator> 11538fd1498Szrj set(_InputIterator __first, _InputIterator __last, 11638fd1498Szrj const allocator_type& __a) 11738fd1498Szrj : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first, 11838fd1498Szrj __last)), 11938fd1498Szrj __gnu_debug::__base(__last), __a) { } 12038fd1498Szrj 12138fd1498Szrj ~set() = default; 12238fd1498Szrj #endif 12338fd1498Szrj 12438fd1498Szrj explicit set(const _Compare& __comp, 12538fd1498Szrj const _Allocator& __a = _Allocator()) 12638fd1498Szrj : _Base(__comp, __a) { } 12738fd1498Szrj 12838fd1498Szrj template<typename _InputIterator> 12938fd1498Szrj set(_InputIterator __first, _InputIterator __last, 13038fd1498Szrj const _Compare& __comp = _Compare(), 13138fd1498Szrj const _Allocator& __a = _Allocator()) 13238fd1498Szrj : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first, 13338fd1498Szrj __last)), 13438fd1498Szrj __gnu_debug::__base(__last), 13538fd1498Szrj __comp, __a) { } 13638fd1498Szrj 13738fd1498Szrj set(const _Base& __x) 13838fd1498Szrj : _Base(__x) { } 13938fd1498Szrj 14038fd1498Szrj #if __cplusplus < 201103L 14138fd1498Szrj set& 14238fd1498Szrj operator=(const set& __x) 14338fd1498Szrj { 14438fd1498Szrj this->_M_safe() = __x; 14538fd1498Szrj _M_base() = __x; 14638fd1498Szrj return *this; 14738fd1498Szrj } 14838fd1498Szrj #else 14938fd1498Szrj set& 15038fd1498Szrj operator=(const set&) = default; 15138fd1498Szrj 15238fd1498Szrj set& 15338fd1498Szrj operator=(set&&) = default; 15438fd1498Szrj 15538fd1498Szrj set& 15638fd1498Szrj operator=(initializer_list<value_type> __l) 15738fd1498Szrj { 15838fd1498Szrj _M_base() = __l; 15938fd1498Szrj this->_M_invalidate_all(); 16038fd1498Szrj return *this; 16138fd1498Szrj } 16238fd1498Szrj #endif 16338fd1498Szrj 16438fd1498Szrj using _Base::get_allocator; 16538fd1498Szrj 16638fd1498Szrj // iterators: 16738fd1498Szrj iterator 16838fd1498Szrj begin() _GLIBCXX_NOEXCEPT 16938fd1498Szrj { return iterator(_Base::begin(), this); } 17038fd1498Szrj 17138fd1498Szrj const_iterator 17238fd1498Szrj begin() const _GLIBCXX_NOEXCEPT 17338fd1498Szrj { return const_iterator(_Base::begin(), this); } 17438fd1498Szrj 17538fd1498Szrj iterator 17638fd1498Szrj end() _GLIBCXX_NOEXCEPT 17738fd1498Szrj { return iterator(_Base::end(), this); } 17838fd1498Szrj 17938fd1498Szrj const_iterator 18038fd1498Szrj end() const _GLIBCXX_NOEXCEPT 18138fd1498Szrj { return const_iterator(_Base::end(), this); } 18238fd1498Szrj 18338fd1498Szrj reverse_iterator 18438fd1498Szrj rbegin() _GLIBCXX_NOEXCEPT 18538fd1498Szrj { return reverse_iterator(end()); } 18638fd1498Szrj 18738fd1498Szrj const_reverse_iterator 18838fd1498Szrj rbegin() const _GLIBCXX_NOEXCEPT 18938fd1498Szrj { return const_reverse_iterator(end()); } 19038fd1498Szrj 19138fd1498Szrj reverse_iterator 19238fd1498Szrj rend() _GLIBCXX_NOEXCEPT 19338fd1498Szrj { return reverse_iterator(begin()); } 19438fd1498Szrj 19538fd1498Szrj const_reverse_iterator 19638fd1498Szrj rend() const _GLIBCXX_NOEXCEPT 19738fd1498Szrj { return const_reverse_iterator(begin()); } 19838fd1498Szrj 19938fd1498Szrj #if __cplusplus >= 201103L 20038fd1498Szrj const_iterator 20138fd1498Szrj cbegin() const noexcept 20238fd1498Szrj { return const_iterator(_Base::begin(), this); } 20338fd1498Szrj 20438fd1498Szrj const_iterator 20538fd1498Szrj cend() const noexcept 20638fd1498Szrj { return const_iterator(_Base::end(), this); } 20738fd1498Szrj 20838fd1498Szrj const_reverse_iterator 20938fd1498Szrj crbegin() const noexcept 21038fd1498Szrj { return const_reverse_iterator(end()); } 21138fd1498Szrj 21238fd1498Szrj const_reverse_iterator 21338fd1498Szrj crend() const noexcept 21438fd1498Szrj { return const_reverse_iterator(begin()); } 21538fd1498Szrj #endif 21638fd1498Szrj 21738fd1498Szrj // capacity: 21838fd1498Szrj using _Base::empty; 21938fd1498Szrj using _Base::size; 22038fd1498Szrj using _Base::max_size; 22138fd1498Szrj 22238fd1498Szrj // modifiers: 22338fd1498Szrj #if __cplusplus >= 201103L 22438fd1498Szrj template<typename... _Args> 22538fd1498Szrj std::pair<iterator, bool> 22638fd1498Szrj emplace(_Args&&... __args) 22738fd1498Szrj { 22838fd1498Szrj auto __res = _Base::emplace(std::forward<_Args>(__args)...); 22938fd1498Szrj return std::pair<iterator, bool>(iterator(__res.first, this), 23038fd1498Szrj __res.second); 23138fd1498Szrj } 23238fd1498Szrj 23338fd1498Szrj template<typename... _Args> 23438fd1498Szrj iterator 23538fd1498Szrj emplace_hint(const_iterator __pos, _Args&&... __args) 23638fd1498Szrj { 23738fd1498Szrj __glibcxx_check_insert(__pos); 23838fd1498Szrj return iterator(_Base::emplace_hint(__pos.base(), 23938fd1498Szrj std::forward<_Args>(__args)...), 24038fd1498Szrj this); 24138fd1498Szrj } 24238fd1498Szrj #endif 24338fd1498Szrj 24438fd1498Szrj std::pair<iterator, bool> 24538fd1498Szrj insert(const value_type& __x) 24638fd1498Szrj { 24738fd1498Szrj std::pair<_Base_iterator, bool> __res = _Base::insert(__x); 24838fd1498Szrj return std::pair<iterator, bool>(iterator(__res.first, this), 24938fd1498Szrj __res.second); 25038fd1498Szrj } 25138fd1498Szrj 25238fd1498Szrj #if __cplusplus >= 201103L 25338fd1498Szrj std::pair<iterator, bool> 25438fd1498Szrj insert(value_type&& __x) 25538fd1498Szrj { 25638fd1498Szrj std::pair<_Base_iterator, bool> __res 25738fd1498Szrj = _Base::insert(std::move(__x)); 25838fd1498Szrj return std::pair<iterator, bool>(iterator(__res.first, this), 25938fd1498Szrj __res.second); 26038fd1498Szrj } 26138fd1498Szrj #endif 26238fd1498Szrj 26338fd1498Szrj iterator 26438fd1498Szrj insert(const_iterator __position, const value_type& __x) 26538fd1498Szrj { 26638fd1498Szrj __glibcxx_check_insert(__position); 26738fd1498Szrj return iterator(_Base::insert(__position.base(), __x), this); 26838fd1498Szrj } 26938fd1498Szrj 27038fd1498Szrj #if __cplusplus >= 201103L 27138fd1498Szrj iterator 27238fd1498Szrj insert(const_iterator __position, value_type&& __x) 27338fd1498Szrj { 27438fd1498Szrj __glibcxx_check_insert(__position); 27538fd1498Szrj return iterator(_Base::insert(__position.base(), std::move(__x)), 27638fd1498Szrj this); 27738fd1498Szrj } 27838fd1498Szrj #endif 27938fd1498Szrj 28038fd1498Szrj template <typename _InputIterator> 28138fd1498Szrj void 28238fd1498Szrj insert(_InputIterator __first, _InputIterator __last) 28338fd1498Szrj { 28438fd1498Szrj typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; 28538fd1498Szrj __glibcxx_check_valid_range2(__first, __last, __dist); 28638fd1498Szrj 28738fd1498Szrj if (__dist.second >= __gnu_debug::__dp_sign) 28838fd1498Szrj _Base::insert(__gnu_debug::__unsafe(__first), 28938fd1498Szrj __gnu_debug::__unsafe(__last)); 29038fd1498Szrj else 29138fd1498Szrj _Base::insert(__first, __last); 29238fd1498Szrj } 29338fd1498Szrj 29438fd1498Szrj #if __cplusplus >= 201103L 29538fd1498Szrj void 29638fd1498Szrj insert(initializer_list<value_type> __l) 29738fd1498Szrj { _Base::insert(__l); } 29838fd1498Szrj #endif 29938fd1498Szrj 30038fd1498Szrj #if __cplusplus > 201402L 30138fd1498Szrj using node_type = typename _Base::node_type; 30238fd1498Szrj using insert_return_type = _Node_insert_return<iterator, node_type>; 30338fd1498Szrj 30438fd1498Szrj node_type 30538fd1498Szrj extract(const_iterator __position) 30638fd1498Szrj { 30738fd1498Szrj __glibcxx_check_erase(__position); 30838fd1498Szrj this->_M_invalidate_if(_Equal(__position.base())); 30938fd1498Szrj return _Base::extract(__position.base()); 31038fd1498Szrj } 31138fd1498Szrj 31238fd1498Szrj node_type 31338fd1498Szrj extract(const key_type& __key) 31438fd1498Szrj { 31538fd1498Szrj const auto __position = find(__key); 31638fd1498Szrj if (__position != end()) 31738fd1498Szrj return extract(__position); 31838fd1498Szrj return {}; 31938fd1498Szrj } 32038fd1498Szrj 32138fd1498Szrj insert_return_type 32238fd1498Szrj insert(node_type&& __nh) 32338fd1498Szrj { 32438fd1498Szrj auto __ret = _Base::insert(std::move(__nh)); 32538fd1498Szrj iterator __pos = iterator(__ret.position, this); 32638fd1498Szrj return { __pos, __ret.inserted, std::move(__ret.node) }; 32738fd1498Szrj } 32838fd1498Szrj 32938fd1498Szrj iterator 33038fd1498Szrj insert(const_iterator __hint, node_type&& __nh) 33138fd1498Szrj { 33238fd1498Szrj __glibcxx_check_insert(__hint); 33338fd1498Szrj return iterator(_Base::insert(__hint.base(), std::move(__nh)), this); 33438fd1498Szrj } 33538fd1498Szrj 33638fd1498Szrj using _Base::merge; 33738fd1498Szrj #endif // C++17 33838fd1498Szrj 33938fd1498Szrj #if __cplusplus >= 201103L 34038fd1498Szrj iterator 34138fd1498Szrj erase(const_iterator __position) 34238fd1498Szrj { 34338fd1498Szrj __glibcxx_check_erase(__position); 34438fd1498Szrj this->_M_invalidate_if(_Equal(__position.base())); 34538fd1498Szrj return iterator(_Base::erase(__position.base()), this); 34638fd1498Szrj } 34738fd1498Szrj #else 34838fd1498Szrj void 34938fd1498Szrj erase(iterator __position) 35038fd1498Szrj { 35138fd1498Szrj __glibcxx_check_erase(__position); 35238fd1498Szrj this->_M_invalidate_if(_Equal(__position.base())); 35338fd1498Szrj _Base::erase(__position.base()); 35438fd1498Szrj } 35538fd1498Szrj #endif 35638fd1498Szrj 35738fd1498Szrj size_type 35838fd1498Szrj erase(const key_type& __x) 35938fd1498Szrj { 36038fd1498Szrj _Base_iterator __victim = _Base::find(__x); 36138fd1498Szrj if (__victim == _Base::end()) 36238fd1498Szrj return 0; 36338fd1498Szrj else 36438fd1498Szrj { 36538fd1498Szrj this->_M_invalidate_if(_Equal(__victim)); 36638fd1498Szrj _Base::erase(__victim); 36738fd1498Szrj return 1; 36838fd1498Szrj } 36938fd1498Szrj } 37038fd1498Szrj 37138fd1498Szrj #if __cplusplus >= 201103L 37238fd1498Szrj iterator 37338fd1498Szrj erase(const_iterator __first, const_iterator __last) 37438fd1498Szrj { 37538fd1498Szrj // _GLIBCXX_RESOLVE_LIB_DEFECTS 37638fd1498Szrj // 151. can't currently clear() empty container 37738fd1498Szrj __glibcxx_check_erase_range(__first, __last); 37838fd1498Szrj for (_Base_const_iterator __victim = __first.base(); 37938fd1498Szrj __victim != __last.base(); ++__victim) 38038fd1498Szrj { 38138fd1498Szrj _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), 38238fd1498Szrj _M_message(__gnu_debug::__msg_valid_range) 38338fd1498Szrj ._M_iterator(__first, "first") 38438fd1498Szrj ._M_iterator(__last, "last")); 38538fd1498Szrj this->_M_invalidate_if(_Equal(__victim)); 38638fd1498Szrj } 38738fd1498Szrj return iterator(_Base::erase(__first.base(), __last.base()), this); 38838fd1498Szrj } 38938fd1498Szrj #else 39038fd1498Szrj void 39138fd1498Szrj erase(iterator __first, iterator __last) 39238fd1498Szrj { 39338fd1498Szrj // _GLIBCXX_RESOLVE_LIB_DEFECTS 39438fd1498Szrj // 151. can't currently clear() empty container 39538fd1498Szrj __glibcxx_check_erase_range(__first, __last); 39638fd1498Szrj for (_Base_iterator __victim = __first.base(); 39738fd1498Szrj __victim != __last.base(); ++__victim) 39838fd1498Szrj { 39938fd1498Szrj _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), 40038fd1498Szrj _M_message(__gnu_debug::__msg_valid_range) 40138fd1498Szrj ._M_iterator(__first, "first") 40238fd1498Szrj ._M_iterator(__last, "last")); 40338fd1498Szrj this->_M_invalidate_if(_Equal(__victim)); 40438fd1498Szrj } 40538fd1498Szrj _Base::erase(__first.base(), __last.base()); 40638fd1498Szrj } 40738fd1498Szrj #endif 40838fd1498Szrj 40938fd1498Szrj void 41038fd1498Szrj swap(set& __x) 41138fd1498Szrj _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) 41238fd1498Szrj { 41338fd1498Szrj _Safe::_M_swap(__x); 41438fd1498Szrj _Base::swap(__x); 41538fd1498Szrj } 41638fd1498Szrj 41738fd1498Szrj void 41838fd1498Szrj clear() _GLIBCXX_NOEXCEPT 41938fd1498Szrj { 42038fd1498Szrj this->_M_invalidate_all(); 42138fd1498Szrj _Base::clear(); 42238fd1498Szrj } 42338fd1498Szrj 42438fd1498Szrj // observers: 42538fd1498Szrj using _Base::key_comp; 42638fd1498Szrj using _Base::value_comp; 42738fd1498Szrj 42838fd1498Szrj // set operations: 42938fd1498Szrj iterator 43038fd1498Szrj find(const key_type& __x) 43138fd1498Szrj { return iterator(_Base::find(__x), this); } 43238fd1498Szrj 43338fd1498Szrj // _GLIBCXX_RESOLVE_LIB_DEFECTS 43438fd1498Szrj // 214. set::find() missing const overload 43538fd1498Szrj const_iterator 43638fd1498Szrj find(const key_type& __x) const 43738fd1498Szrj { return const_iterator(_Base::find(__x), this); } 43838fd1498Szrj 43938fd1498Szrj #if __cplusplus > 201103L 44038fd1498Szrj template<typename _Kt, 44138fd1498Szrj typename _Req = 44238fd1498Szrj typename __has_is_transparent<_Compare, _Kt>::type> 44338fd1498Szrj iterator 44438fd1498Szrj find(const _Kt& __x) 44538fd1498Szrj { return { _Base::find(__x), this }; } 44638fd1498Szrj 44738fd1498Szrj template<typename _Kt, 44838fd1498Szrj typename _Req = 44938fd1498Szrj typename __has_is_transparent<_Compare, _Kt>::type> 45038fd1498Szrj const_iterator 45138fd1498Szrj find(const _Kt& __x) const 45238fd1498Szrj { return { _Base::find(__x), this }; } 45338fd1498Szrj #endif 45438fd1498Szrj 45538fd1498Szrj using _Base::count; 45638fd1498Szrj 45738fd1498Szrj iterator 45838fd1498Szrj lower_bound(const key_type& __x) 45938fd1498Szrj { return iterator(_Base::lower_bound(__x), this); } 46038fd1498Szrj 46138fd1498Szrj // _GLIBCXX_RESOLVE_LIB_DEFECTS 46238fd1498Szrj // 214. set::find() missing const overload 46338fd1498Szrj const_iterator 46438fd1498Szrj lower_bound(const key_type& __x) const 46538fd1498Szrj { return const_iterator(_Base::lower_bound(__x), this); } 46638fd1498Szrj 46738fd1498Szrj #if __cplusplus > 201103L 46838fd1498Szrj template<typename _Kt, 46938fd1498Szrj typename _Req = 47038fd1498Szrj typename __has_is_transparent<_Compare, _Kt>::type> 47138fd1498Szrj iterator 47238fd1498Szrj lower_bound(const _Kt& __x) 47338fd1498Szrj { return { _Base::lower_bound(__x), this }; } 47438fd1498Szrj 47538fd1498Szrj template<typename _Kt, 47638fd1498Szrj typename _Req = 47738fd1498Szrj typename __has_is_transparent<_Compare, _Kt>::type> 47838fd1498Szrj const_iterator 47938fd1498Szrj lower_bound(const _Kt& __x) const 48038fd1498Szrj { return { _Base::lower_bound(__x), this }; } 48138fd1498Szrj #endif 48238fd1498Szrj 48338fd1498Szrj iterator 48438fd1498Szrj upper_bound(const key_type& __x) 48538fd1498Szrj { return iterator(_Base::upper_bound(__x), this); } 48638fd1498Szrj 48738fd1498Szrj // _GLIBCXX_RESOLVE_LIB_DEFECTS 48838fd1498Szrj // 214. set::find() missing const overload 48938fd1498Szrj const_iterator 49038fd1498Szrj upper_bound(const key_type& __x) const 49138fd1498Szrj { return const_iterator(_Base::upper_bound(__x), this); } 49238fd1498Szrj 49338fd1498Szrj #if __cplusplus > 201103L 49438fd1498Szrj template<typename _Kt, 49538fd1498Szrj typename _Req = 49638fd1498Szrj typename __has_is_transparent<_Compare, _Kt>::type> 49738fd1498Szrj iterator 49838fd1498Szrj upper_bound(const _Kt& __x) 49938fd1498Szrj { return { _Base::upper_bound(__x), this }; } 50038fd1498Szrj 50138fd1498Szrj template<typename _Kt, 50238fd1498Szrj typename _Req = 50338fd1498Szrj typename __has_is_transparent<_Compare, _Kt>::type> 50438fd1498Szrj const_iterator 50538fd1498Szrj upper_bound(const _Kt& __x) const 50638fd1498Szrj { return { _Base::upper_bound(__x), this }; } 50738fd1498Szrj #endif 50838fd1498Szrj 50938fd1498Szrj std::pair<iterator, iterator> 51038fd1498Szrj equal_range(const key_type& __x) 51138fd1498Szrj { 51238fd1498Szrj std::pair<_Base_iterator, _Base_iterator> __res = 51338fd1498Szrj _Base::equal_range(__x); 51438fd1498Szrj return std::make_pair(iterator(__res.first, this), 51538fd1498Szrj iterator(__res.second, this)); 51638fd1498Szrj } 51738fd1498Szrj 51838fd1498Szrj // _GLIBCXX_RESOLVE_LIB_DEFECTS 51938fd1498Szrj // 214. set::find() missing const overload 52038fd1498Szrj std::pair<const_iterator, const_iterator> 52138fd1498Szrj equal_range(const key_type& __x) const 52238fd1498Szrj { 52338fd1498Szrj std::pair<_Base_const_iterator, _Base_const_iterator> __res = 52438fd1498Szrj _Base::equal_range(__x); 52538fd1498Szrj return std::make_pair(const_iterator(__res.first, this), 52638fd1498Szrj const_iterator(__res.second, this)); 52738fd1498Szrj } 52838fd1498Szrj 52938fd1498Szrj #if __cplusplus > 201103L 53038fd1498Szrj template<typename _Kt, 53138fd1498Szrj typename _Req = 53238fd1498Szrj typename __has_is_transparent<_Compare, _Kt>::type> 53338fd1498Szrj std::pair<iterator, iterator> 53438fd1498Szrj equal_range(const _Kt& __x) 53538fd1498Szrj { 53638fd1498Szrj auto __res = _Base::equal_range(__x); 53738fd1498Szrj return { { __res.first, this }, { __res.second, this } }; 53838fd1498Szrj } 53938fd1498Szrj 54038fd1498Szrj template<typename _Kt, 54138fd1498Szrj typename _Req = 54238fd1498Szrj typename __has_is_transparent<_Compare, _Kt>::type> 54338fd1498Szrj std::pair<const_iterator, const_iterator> 54438fd1498Szrj equal_range(const _Kt& __x) const 54538fd1498Szrj { 54638fd1498Szrj auto __res = _Base::equal_range(__x); 54738fd1498Szrj return { { __res.first, this }, { __res.second, this } }; 54838fd1498Szrj } 54938fd1498Szrj #endif 55038fd1498Szrj 55138fd1498Szrj _Base& 55238fd1498Szrj _M_base() _GLIBCXX_NOEXCEPT { return *this; } 55338fd1498Szrj 55438fd1498Szrj const _Base& 55538fd1498Szrj _M_base() const _GLIBCXX_NOEXCEPT { return *this; } 55638fd1498Szrj }; 55738fd1498Szrj 55838fd1498Szrj #if __cpp_deduction_guides >= 201606 55938fd1498Szrj 56038fd1498Szrj template<typename _InputIterator, 56138fd1498Szrj typename _Compare = 56238fd1498Szrj less<typename iterator_traits<_InputIterator>::value_type>, 56338fd1498Szrj typename _Allocator = 56438fd1498Szrj allocator<typename iterator_traits<_InputIterator>::value_type>, 56538fd1498Szrj typename = _RequireInputIter<_InputIterator>, 56638fd1498Szrj typename = _RequireAllocator<_Allocator>> 56738fd1498Szrj set(_InputIterator, _InputIterator, 56838fd1498Szrj _Compare = _Compare(), _Allocator = _Allocator()) 56938fd1498Szrj -> set<typename iterator_traits<_InputIterator>::value_type, 57038fd1498Szrj _Compare, _Allocator>; 57138fd1498Szrj 57238fd1498Szrj template<typename _Key, typename _Compare = less<_Key>, 57338fd1498Szrj typename _Allocator = allocator<_Key>, 57438fd1498Szrj typename = _RequireAllocator<_Allocator>> 57538fd1498Szrj set(initializer_list<_Key>, 57638fd1498Szrj _Compare = _Compare(), _Allocator = _Allocator()) 57738fd1498Szrj -> set<_Key, _Compare, _Allocator>; 57838fd1498Szrj 57938fd1498Szrj template<typename _InputIterator, typename _Allocator, 58038fd1498Szrj typename = _RequireInputIter<_InputIterator>, 58138fd1498Szrj typename = _RequireAllocator<_Allocator>> 58238fd1498Szrj set(_InputIterator, _InputIterator, _Allocator) 58338fd1498Szrj -> set<typename iterator_traits<_InputIterator>::value_type, 58438fd1498Szrj less<typename iterator_traits<_InputIterator>::value_type>, 58538fd1498Szrj _Allocator>; 58638fd1498Szrj 58738fd1498Szrj template<typename _Key, typename _Allocator, 58838fd1498Szrj typename = _RequireAllocator<_Allocator>> 58938fd1498Szrj set(initializer_list<_Key>, _Allocator) 59038fd1498Szrj -> set<_Key, less<_Key>, _Allocator>; 59138fd1498Szrj 59238fd1498Szrj #endif 59338fd1498Szrj 59438fd1498Szrj template<typename _Key, typename _Compare, typename _Allocator> 59538fd1498Szrj inline bool 59638fd1498Szrj operator==(const set<_Key, _Compare, _Allocator>& __lhs, 59738fd1498Szrj const set<_Key, _Compare, _Allocator>& __rhs) 59838fd1498Szrj { return __lhs._M_base() == __rhs._M_base(); } 59938fd1498Szrj 60038fd1498Szrj template<typename _Key, typename _Compare, typename _Allocator> 60138fd1498Szrj inline bool 60238fd1498Szrj operator!=(const set<_Key, _Compare, _Allocator>& __lhs, 60338fd1498Szrj const set<_Key, _Compare, _Allocator>& __rhs) 60438fd1498Szrj { return __lhs._M_base() != __rhs._M_base(); } 60538fd1498Szrj 60638fd1498Szrj template<typename _Key, typename _Compare, typename _Allocator> 60738fd1498Szrj inline bool 60838fd1498Szrj operator<(const set<_Key, _Compare, _Allocator>& __lhs, 60938fd1498Szrj const set<_Key, _Compare, _Allocator>& __rhs) 61038fd1498Szrj { return __lhs._M_base() < __rhs._M_base(); } 61138fd1498Szrj 61238fd1498Szrj template<typename _Key, typename _Compare, typename _Allocator> 61338fd1498Szrj inline bool 61438fd1498Szrj operator<=(const set<_Key, _Compare, _Allocator>& __lhs, 61538fd1498Szrj const set<_Key, _Compare, _Allocator>& __rhs) 61638fd1498Szrj { return __lhs._M_base() <= __rhs._M_base(); } 61738fd1498Szrj 61838fd1498Szrj template<typename _Key, typename _Compare, typename _Allocator> 61938fd1498Szrj inline bool 62038fd1498Szrj operator>=(const set<_Key, _Compare, _Allocator>& __lhs, 62138fd1498Szrj const set<_Key, _Compare, _Allocator>& __rhs) 62238fd1498Szrj { return __lhs._M_base() >= __rhs._M_base(); } 62338fd1498Szrj 62438fd1498Szrj template<typename _Key, typename _Compare, typename _Allocator> 62538fd1498Szrj inline bool 62638fd1498Szrj operator>(const set<_Key, _Compare, _Allocator>& __lhs, 62738fd1498Szrj const set<_Key, _Compare, _Allocator>& __rhs) 62838fd1498Szrj { return __lhs._M_base() > __rhs._M_base(); } 62938fd1498Szrj 63038fd1498Szrj template<typename _Key, typename _Compare, typename _Allocator> 63138fd1498Szrj void 63238fd1498Szrj swap(set<_Key, _Compare, _Allocator>& __x, 63338fd1498Szrj set<_Key, _Compare, _Allocator>& __y) 63438fd1498Szrj _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) 63538fd1498Szrj { return __x.swap(__y); } 63638fd1498Szrj 63738fd1498Szrj } // namespace __debug 63838fd1498Szrj } // namespace std 63938fd1498Szrj 64038fd1498Szrj #endif 641