Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
Louis Dionne | 9bd9388 | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 2 | //===----------------------------------------------------------------------===// |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3 | // |
Chandler Carruth | d201210 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_SET |
| 11 | #define _LIBCPP_SET |
| 12 | |
| 13 | /* |
| 14 | |
| 15 | set synopsis |
| 16 | |
| 17 | namespace std |
| 18 | { |
| 19 | |
| 20 | template <class Key, class Compare = less<Key>, |
| 21 | class Allocator = allocator<Key>> |
| 22 | class set |
| 23 | { |
| 24 | public: |
| 25 | // types: |
| 26 | typedef Key key_type; |
| 27 | typedef key_type value_type; |
| 28 | typedef Compare key_compare; |
| 29 | typedef key_compare value_compare; |
| 30 | typedef Allocator allocator_type; |
| 31 | typedef typename allocator_type::reference reference; |
| 32 | typedef typename allocator_type::const_reference const_reference; |
| 33 | typedef typename allocator_type::size_type size_type; |
| 34 | typedef typename allocator_type::difference_type difference_type; |
| 35 | typedef typename allocator_type::pointer pointer; |
| 36 | typedef typename allocator_type::const_pointer const_pointer; |
| 37 | |
| 38 | typedef implementation-defined iterator; |
| 39 | typedef implementation-defined const_iterator; |
| 40 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 41 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 42 | typedef unspecified node_type; // C++17 |
| 43 | typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 44 | |
| 45 | // construct/copy/destroy: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 46 | set() |
| 47 | noexcept( |
| 48 | is_nothrow_default_constructible<allocator_type>::value && |
| 49 | is_nothrow_default_constructible<key_compare>::value && |
| 50 | is_nothrow_copy_constructible<key_compare>::value); |
| 51 | explicit set(const value_compare& comp); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 52 | set(const value_compare& comp, const allocator_type& a); |
| 53 | template <class InputIterator> |
| 54 | set(InputIterator first, InputIterator last, |
| 55 | const value_compare& comp = value_compare()); |
| 56 | template <class InputIterator> |
| 57 | set(InputIterator first, InputIterator last, const value_compare& comp, |
| 58 | const allocator_type& a); |
| 59 | set(const set& s); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 60 | set(set&& s) |
| 61 | noexcept( |
| 62 | is_nothrow_move_constructible<allocator_type>::value && |
| 63 | is_nothrow_move_constructible<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 64 | explicit set(const allocator_type& a); |
| 65 | set(const set& s, const allocator_type& a); |
| 66 | set(set&& s, const allocator_type& a); |
| 67 | set(initializer_list<value_type> il, const value_compare& comp = value_compare()); |
| 68 | set(initializer_list<value_type> il, const value_compare& comp, |
| 69 | const allocator_type& a); |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 70 | template <class InputIterator> |
| 71 | set(InputIterator first, InputIterator last, const allocator_type& a) |
| 72 | : set(first, last, Compare(), a) {} // C++14 |
| 73 | set(initializer_list<value_type> il, const allocator_type& a) |
| 74 | : set(il, Compare(), a) {} // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 75 | ~set(); |
| 76 | |
| 77 | set& operator=(const set& s); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 78 | set& operator=(set&& s) |
| 79 | noexcept( |
| 80 | allocator_type::propagate_on_container_move_assignment::value && |
| 81 | is_nothrow_move_assignable<allocator_type>::value && |
| 82 | is_nothrow_move_assignable<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 83 | set& operator=(initializer_list<value_type> il); |
| 84 | |
| 85 | // iterators: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 86 | iterator begin() noexcept; |
| 87 | const_iterator begin() const noexcept; |
| 88 | iterator end() noexcept; |
| 89 | const_iterator end() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 90 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 91 | reverse_iterator rbegin() noexcept; |
| 92 | const_reverse_iterator rbegin() const noexcept; |
| 93 | reverse_iterator rend() noexcept; |
| 94 | const_reverse_iterator rend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 95 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 96 | const_iterator cbegin() const noexcept; |
| 97 | const_iterator cend() const noexcept; |
| 98 | const_reverse_iterator crbegin() const noexcept; |
| 99 | const_reverse_iterator crend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 100 | |
| 101 | // capacity: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 102 | bool empty() const noexcept; |
| 103 | size_type size() const noexcept; |
| 104 | size_type max_size() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 105 | |
| 106 | // modifiers: |
| 107 | template <class... Args> |
| 108 | pair<iterator, bool> emplace(Args&&... args); |
| 109 | template <class... Args> |
| 110 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 111 | pair<iterator,bool> insert(const value_type& v); |
| 112 | pair<iterator,bool> insert(value_type&& v); |
| 113 | iterator insert(const_iterator position, const value_type& v); |
| 114 | iterator insert(const_iterator position, value_type&& v); |
| 115 | template <class InputIterator> |
| 116 | void insert(InputIterator first, InputIterator last); |
| 117 | void insert(initializer_list<value_type> il); |
| 118 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 119 | node_type extract(const_iterator position); // C++17 |
| 120 | node_type extract(const key_type& x); // C++17 |
| 121 | insert_return_type insert(node_type&& nh); // C++17 |
| 122 | iterator insert(const_iterator hint, node_type&& nh); // C++17 |
| 123 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 124 | iterator erase(const_iterator position); |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 125 | iterator erase(iterator position); // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 126 | size_type erase(const key_type& k); |
| 127 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 128 | void clear() noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 129 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 130 | template<class C2> |
| 131 | void merge(set<Key, C2, Allocator>& source); // C++17 |
| 132 | template<class C2> |
| 133 | void merge(set<Key, C2, Allocator>&& source); // C++17 |
| 134 | template<class C2> |
| 135 | void merge(multiset<Key, C2, Allocator>& source); // C++17 |
| 136 | template<class C2> |
| 137 | void merge(multiset<Key, C2, Allocator>&& source); // C++17 |
| 138 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 139 | void swap(set& s) |
| 140 | noexcept( |
| 141 | __is_nothrow_swappable<key_compare>::value && |
| 142 | (!allocator_type::propagate_on_container_swap::value || |
| 143 | __is_nothrow_swappable<allocator_type>::value)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 144 | |
| 145 | // observers: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 146 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 147 | key_compare key_comp() const; |
| 148 | value_compare value_comp() const; |
| 149 | |
| 150 | // set operations: |
| 151 | iterator find(const key_type& k); |
| 152 | const_iterator find(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 153 | template<typename K> |
| 154 | iterator find(const K& x); |
| 155 | template<typename K> |
| 156 | const_iterator find(const K& x) const; // C++14 |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 157 | |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 158 | template<typename K> |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 159 | size_type count(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 160 | size_type count(const key_type& k) const; |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 161 | |
| 162 | bool contains(const key_type& x) const; // C++20 |
| 163 | template<class K> bool contains(const K& x) const; // C++20 |
| 164 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 165 | iterator lower_bound(const key_type& k); |
| 166 | const_iterator lower_bound(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 167 | template<typename K> |
| 168 | iterator lower_bound(const K& x); // C++14 |
| 169 | template<typename K> |
| 170 | const_iterator lower_bound(const K& x) const; // C++14 |
| 171 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 172 | iterator upper_bound(const key_type& k); |
| 173 | const_iterator upper_bound(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 174 | template<typename K> |
| 175 | iterator upper_bound(const K& x); // C++14 |
| 176 | template<typename K> |
| 177 | const_iterator upper_bound(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 178 | pair<iterator,iterator> equal_range(const key_type& k); |
| 179 | pair<const_iterator,const_iterator> equal_range(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 180 | template<typename K> |
| 181 | pair<iterator,iterator> equal_range(const K& x); // C++14 |
| 182 | template<typename K> |
| 183 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 184 | }; |
| 185 | |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 186 | template <class InputIterator, |
| 187 | class Compare = less<typename iterator_traits<InputIterator>::value_type>, |
| 188 | class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> |
| 189 | set(InputIterator, InputIterator, |
| 190 | Compare = Compare(), Allocator = Allocator()) |
| 191 | -> set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17 |
| 192 | |
| 193 | template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>> |
| 194 | set(initializer_list<Key>, Compare = Compare(), Allocator = Allocator()) |
| 195 | -> set<Key, Compare, Allocator>; // C++17 |
| 196 | |
| 197 | template<class InputIterator, class Allocator> |
| 198 | set(InputIterator, InputIterator, Allocator) |
| 199 | -> set<typename iterator_traits<InputIterator>::value_type, |
| 200 | less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17 |
| 201 | |
| 202 | template<class Key, class Allocator> |
| 203 | set(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>; // C++17 |
| 204 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 205 | template <class Key, class Compare, class Allocator> |
| 206 | bool |
| 207 | operator==(const set<Key, Compare, Allocator>& x, |
| 208 | const set<Key, Compare, Allocator>& y); |
| 209 | |
| 210 | template <class Key, class Compare, class Allocator> |
| 211 | bool |
| 212 | operator< (const set<Key, Compare, Allocator>& x, |
| 213 | const set<Key, Compare, Allocator>& y); |
| 214 | |
| 215 | template <class Key, class Compare, class Allocator> |
| 216 | bool |
| 217 | operator!=(const set<Key, Compare, Allocator>& x, |
| 218 | const set<Key, Compare, Allocator>& y); |
| 219 | |
| 220 | template <class Key, class Compare, class Allocator> |
| 221 | bool |
| 222 | operator> (const set<Key, Compare, Allocator>& x, |
| 223 | const set<Key, Compare, Allocator>& y); |
| 224 | |
| 225 | template <class Key, class Compare, class Allocator> |
| 226 | bool |
| 227 | operator>=(const set<Key, Compare, Allocator>& x, |
| 228 | const set<Key, Compare, Allocator>& y); |
| 229 | |
| 230 | template <class Key, class Compare, class Allocator> |
| 231 | bool |
| 232 | operator<=(const set<Key, Compare, Allocator>& x, |
| 233 | const set<Key, Compare, Allocator>& y); |
| 234 | |
| 235 | // specialized algorithms: |
| 236 | template <class Key, class Compare, class Allocator> |
| 237 | void |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 238 | swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y) |
| 239 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 240 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 241 | template <class Key, class Compare, class Allocator, class Predicate> |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 242 | typename set<Key, Compare, Allocator>::size_type |
| 243 | erase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20 |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 244 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 245 | template <class Key, class Compare = less<Key>, |
| 246 | class Allocator = allocator<Key>> |
| 247 | class multiset |
| 248 | { |
| 249 | public: |
| 250 | // types: |
| 251 | typedef Key key_type; |
| 252 | typedef key_type value_type; |
| 253 | typedef Compare key_compare; |
| 254 | typedef key_compare value_compare; |
| 255 | typedef Allocator allocator_type; |
| 256 | typedef typename allocator_type::reference reference; |
| 257 | typedef typename allocator_type::const_reference const_reference; |
| 258 | typedef typename allocator_type::size_type size_type; |
| 259 | typedef typename allocator_type::difference_type difference_type; |
| 260 | typedef typename allocator_type::pointer pointer; |
| 261 | typedef typename allocator_type::const_pointer const_pointer; |
| 262 | |
| 263 | typedef implementation-defined iterator; |
| 264 | typedef implementation-defined const_iterator; |
| 265 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 266 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 267 | typedef unspecified node_type; // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 268 | |
| 269 | // construct/copy/destroy: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 270 | multiset() |
| 271 | noexcept( |
| 272 | is_nothrow_default_constructible<allocator_type>::value && |
| 273 | is_nothrow_default_constructible<key_compare>::value && |
| 274 | is_nothrow_copy_constructible<key_compare>::value); |
| 275 | explicit multiset(const value_compare& comp); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 276 | multiset(const value_compare& comp, const allocator_type& a); |
| 277 | template <class InputIterator> |
| 278 | multiset(InputIterator first, InputIterator last, |
| 279 | const value_compare& comp = value_compare()); |
| 280 | template <class InputIterator> |
| 281 | multiset(InputIterator first, InputIterator last, |
| 282 | const value_compare& comp, const allocator_type& a); |
| 283 | multiset(const multiset& s); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 284 | multiset(multiset&& s) |
| 285 | noexcept( |
| 286 | is_nothrow_move_constructible<allocator_type>::value && |
| 287 | is_nothrow_move_constructible<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 288 | explicit multiset(const allocator_type& a); |
| 289 | multiset(const multiset& s, const allocator_type& a); |
| 290 | multiset(multiset&& s, const allocator_type& a); |
| 291 | multiset(initializer_list<value_type> il, const value_compare& comp = value_compare()); |
| 292 | multiset(initializer_list<value_type> il, const value_compare& comp, |
| 293 | const allocator_type& a); |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 294 | template <class InputIterator> |
| 295 | multiset(InputIterator first, InputIterator last, const allocator_type& a) |
| 296 | : set(first, last, Compare(), a) {} // C++14 |
| 297 | multiset(initializer_list<value_type> il, const allocator_type& a) |
| 298 | : set(il, Compare(), a) {} // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 299 | ~multiset(); |
| 300 | |
| 301 | multiset& operator=(const multiset& s); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 302 | multiset& operator=(multiset&& s) |
| 303 | noexcept( |
| 304 | allocator_type::propagate_on_container_move_assignment::value && |
| 305 | is_nothrow_move_assignable<allocator_type>::value && |
| 306 | is_nothrow_move_assignable<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 307 | multiset& operator=(initializer_list<value_type> il); |
| 308 | |
| 309 | // iterators: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 310 | iterator begin() noexcept; |
| 311 | const_iterator begin() const noexcept; |
| 312 | iterator end() noexcept; |
| 313 | const_iterator end() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 314 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 315 | reverse_iterator rbegin() noexcept; |
| 316 | const_reverse_iterator rbegin() const noexcept; |
| 317 | reverse_iterator rend() noexcept; |
| 318 | const_reverse_iterator rend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 319 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 320 | const_iterator cbegin() const noexcept; |
| 321 | const_iterator cend() const noexcept; |
| 322 | const_reverse_iterator crbegin() const noexcept; |
| 323 | const_reverse_iterator crend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 324 | |
| 325 | // capacity: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 326 | bool empty() const noexcept; |
| 327 | size_type size() const noexcept; |
| 328 | size_type max_size() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 329 | |
| 330 | // modifiers: |
| 331 | template <class... Args> |
| 332 | iterator emplace(Args&&... args); |
| 333 | template <class... Args> |
| 334 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 335 | iterator insert(const value_type& v); |
| 336 | iterator insert(value_type&& v); |
| 337 | iterator insert(const_iterator position, const value_type& v); |
| 338 | iterator insert(const_iterator position, value_type&& v); |
| 339 | template <class InputIterator> |
| 340 | void insert(InputIterator first, InputIterator last); |
| 341 | void insert(initializer_list<value_type> il); |
| 342 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 343 | node_type extract(const_iterator position); // C++17 |
| 344 | node_type extract(const key_type& x); // C++17 |
| 345 | iterator insert(node_type&& nh); // C++17 |
| 346 | iterator insert(const_iterator hint, node_type&& nh); // C++17 |
| 347 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 348 | iterator erase(const_iterator position); |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 349 | iterator erase(iterator position); // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 350 | size_type erase(const key_type& k); |
| 351 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 352 | void clear() noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 353 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 354 | template<class C2> |
| 355 | void merge(multiset<Key, C2, Allocator>& source); // C++17 |
| 356 | template<class C2> |
| 357 | void merge(multiset<Key, C2, Allocator>&& source); // C++17 |
| 358 | template<class C2> |
| 359 | void merge(set<Key, C2, Allocator>& source); // C++17 |
| 360 | template<class C2> |
| 361 | void merge(set<Key, C2, Allocator>&& source); // C++17 |
| 362 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 363 | void swap(multiset& s) |
| 364 | noexcept( |
| 365 | __is_nothrow_swappable<key_compare>::value && |
| 366 | (!allocator_type::propagate_on_container_swap::value || |
| 367 | __is_nothrow_swappable<allocator_type>::value)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 368 | |
| 369 | // observers: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 370 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 371 | key_compare key_comp() const; |
| 372 | value_compare value_comp() const; |
| 373 | |
| 374 | // set operations: |
| 375 | iterator find(const key_type& k); |
| 376 | const_iterator find(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 377 | template<typename K> |
| 378 | iterator find(const K& x); |
| 379 | template<typename K> |
| 380 | const_iterator find(const K& x) const; // C++14 |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 381 | |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 382 | template<typename K> |
| 383 | size_type count(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 384 | size_type count(const key_type& k) const; |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 385 | |
| 386 | bool contains(const key_type& x) const; // C++20 |
| 387 | template<class K> bool contains(const K& x) const; // C++20 |
| 388 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 389 | iterator lower_bound(const key_type& k); |
| 390 | const_iterator lower_bound(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 391 | template<typename K> |
| 392 | iterator lower_bound(const K& x); // C++14 |
| 393 | template<typename K> |
| 394 | const_iterator lower_bound(const K& x) const; // C++14 |
| 395 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 396 | iterator upper_bound(const key_type& k); |
| 397 | const_iterator upper_bound(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 398 | template<typename K> |
| 399 | iterator upper_bound(const K& x); // C++14 |
| 400 | template<typename K> |
| 401 | const_iterator upper_bound(const K& x) const; // C++14 |
| 402 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 403 | pair<iterator,iterator> equal_range(const key_type& k); |
| 404 | pair<const_iterator,const_iterator> equal_range(const key_type& k) const; |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 405 | template<typename K> |
| 406 | pair<iterator,iterator> equal_range(const K& x); // C++14 |
| 407 | template<typename K> |
| 408 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 409 | }; |
| 410 | |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 411 | template <class InputIterator, |
| 412 | class Compare = less<typename iterator_traits<InputIterator>::value_type>, |
| 413 | class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> |
| 414 | multiset(InputIterator, InputIterator, |
| 415 | Compare = Compare(), Allocator = Allocator()) |
| 416 | -> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17 |
| 417 | |
| 418 | template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>> |
| 419 | multiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator()) |
| 420 | -> multiset<Key, Compare, Allocator>; // C++17 |
| 421 | |
| 422 | template<class InputIterator, class Allocator> |
| 423 | multiset(InputIterator, InputIterator, Allocator) |
| 424 | -> multiset<typename iterator_traits<InputIterator>::value_type, |
| 425 | less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17 |
| 426 | |
| 427 | template<class Key, class Allocator> |
| 428 | multiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>; // C++17 |
| 429 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 430 | template <class Key, class Compare, class Allocator> |
| 431 | bool |
| 432 | operator==(const multiset<Key, Compare, Allocator>& x, |
| 433 | const multiset<Key, Compare, Allocator>& y); |
| 434 | |
| 435 | template <class Key, class Compare, class Allocator> |
| 436 | bool |
| 437 | operator< (const multiset<Key, Compare, Allocator>& x, |
| 438 | const multiset<Key, Compare, Allocator>& y); |
| 439 | |
| 440 | template <class Key, class Compare, class Allocator> |
| 441 | bool |
| 442 | operator!=(const multiset<Key, Compare, Allocator>& x, |
| 443 | const multiset<Key, Compare, Allocator>& y); |
| 444 | |
| 445 | template <class Key, class Compare, class Allocator> |
| 446 | bool |
| 447 | operator> (const multiset<Key, Compare, Allocator>& x, |
| 448 | const multiset<Key, Compare, Allocator>& y); |
| 449 | |
| 450 | template <class Key, class Compare, class Allocator> |
| 451 | bool |
| 452 | operator>=(const multiset<Key, Compare, Allocator>& x, |
| 453 | const multiset<Key, Compare, Allocator>& y); |
| 454 | |
| 455 | template <class Key, class Compare, class Allocator> |
| 456 | bool |
| 457 | operator<=(const multiset<Key, Compare, Allocator>& x, |
| 458 | const multiset<Key, Compare, Allocator>& y); |
| 459 | |
| 460 | // specialized algorithms: |
| 461 | template <class Key, class Compare, class Allocator> |
| 462 | void |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 463 | swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y) |
| 464 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 465 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 466 | template <class Key, class Compare, class Allocator, class Predicate> |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 467 | typename multiset<Key, Compare, Allocator>::size_type |
| 468 | erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 469 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 470 | } // std |
| 471 | |
| 472 | */ |
| 473 | |
| 474 | #include <__config> |
Arthur O'Dwyer | 597cac4 | 2021-05-12 23:04:03 -0400 | [diff] [blame] | 475 | #include <__debug> |
Christopher Di Bella | 55d7a82 | 2021-07-01 09:25:35 -0400 | [diff] [blame] | 476 | #include <__functional/is_transparent.h> |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 477 | #include <__iterator/iterator_traits.h> |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 478 | #include <__node_handle> |
Arthur O'Dwyer | 597cac4 | 2021-05-12 23:04:03 -0400 | [diff] [blame] | 479 | #include <__tree> |
Christopher Di Bella | 41f26e8 | 2021-06-05 02:47:47 +0000 | [diff] [blame] | 480 | #include <__utility/forward.h> |
Arthur O'Dwyer | 7deec12 | 2021-03-24 18:19:12 -0400 | [diff] [blame] | 481 | #include <compare> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 482 | #include <functional> |
Arthur O'Dwyer | 7deec12 | 2021-03-24 18:19:12 -0400 | [diff] [blame] | 483 | #include <initializer_list> |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 484 | #include <iterator> // __libcpp_erase_if_container |
Marshall Clow | 0a1e750 | 2018-09-12 19:41:40 +0000 | [diff] [blame] | 485 | #include <version> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 486 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 487 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 488 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 489 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 490 | |
| 491 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 492 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 493 | template <class _Key, class _Compare, class _Allocator> |
| 494 | class multiset; |
| 495 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 496 | template <class _Key, class _Compare = less<_Key>, |
| 497 | class _Allocator = allocator<_Key> > |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 498 | class _LIBCPP_TEMPLATE_VIS set |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 499 | { |
| 500 | public: |
| 501 | // types: |
| 502 | typedef _Key key_type; |
| 503 | typedef key_type value_type; |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 504 | typedef __identity_t<_Compare> key_compare; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 505 | typedef key_compare value_compare; |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 506 | typedef __identity_t<_Allocator> allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 507 | typedef value_type& reference; |
| 508 | typedef const value_type& const_reference; |
| 509 | |
Marshall Clow | 5128cf3 | 2015-11-26 01:24:04 +0000 | [diff] [blame] | 510 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 511 | "Allocator::value_type must be same type as value_type"); |
| 512 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 513 | private: |
| 514 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 515 | typedef allocator_traits<allocator_type> __alloc_traits; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 516 | |
| 517 | __base __tree_; |
| 518 | |
| 519 | public: |
| 520 | typedef typename __base::pointer pointer; |
| 521 | typedef typename __base::const_pointer const_pointer; |
| 522 | typedef typename __base::size_type size_type; |
| 523 | typedef typename __base::difference_type difference_type; |
| 524 | typedef typename __base::const_iterator iterator; |
| 525 | typedef typename __base::const_iterator const_iterator; |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 526 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 527 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 528 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 529 | #if _LIBCPP_STD_VER > 14 |
| 530 | typedef __set_node_handle<typename __base::__node, allocator_type> node_type; |
| 531 | typedef __insert_return_type<iterator, node_type> insert_return_type; |
| 532 | #endif |
| 533 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 534 | template <class _Key2, class _Compare2, class _Alloc2> |
| 535 | friend class _LIBCPP_TEMPLATE_VIS set; |
| 536 | template <class _Key2, class _Compare2, class _Alloc2> |
| 537 | friend class _LIBCPP_TEMPLATE_VIS multiset; |
| 538 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 539 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 540 | set() |
| 541 | _NOEXCEPT_( |
| 542 | is_nothrow_default_constructible<allocator_type>::value && |
| 543 | is_nothrow_default_constructible<key_compare>::value && |
| 544 | is_nothrow_copy_constructible<key_compare>::value) |
| 545 | : __tree_(value_compare()) {} |
| 546 | |
| 547 | _LIBCPP_INLINE_VISIBILITY |
| 548 | explicit set(const value_compare& __comp) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 549 | _NOEXCEPT_( |
| 550 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 551 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 552 | : __tree_(__comp) {} |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 553 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 554 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7ed23a7 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 555 | explicit set(const value_compare& __comp, const allocator_type& __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 556 | : __tree_(__comp, __a) {} |
| 557 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 558 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 559 | set(_InputIterator __f, _InputIterator __l, |
| 560 | const value_compare& __comp = value_compare()) |
| 561 | : __tree_(__comp) |
| 562 | { |
| 563 | insert(__f, __l); |
| 564 | } |
| 565 | |
| 566 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 567 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 568 | set(_InputIterator __f, _InputIterator __l, const value_compare& __comp, |
| 569 | const allocator_type& __a) |
| 570 | : __tree_(__comp, __a) |
| 571 | { |
| 572 | insert(__f, __l); |
| 573 | } |
| 574 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 575 | #if _LIBCPP_STD_VER > 11 |
| 576 | template <class _InputIterator> |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 577 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 578 | set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 579 | : set(__f, __l, key_compare(), __a) {} |
| 580 | #endif |
| 581 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 582 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 583 | set(const set& __s) |
| 584 | : __tree_(__s.__tree_) |
| 585 | { |
| 586 | insert(__s.begin(), __s.end()); |
| 587 | } |
| 588 | |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 589 | _LIBCPP_INLINE_VISIBILITY |
| 590 | set& operator=(const set& __s) |
| 591 | { |
| 592 | __tree_ = __s.__tree_; |
| 593 | return *this; |
| 594 | } |
| 595 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 596 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 597 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 598 | set(set&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 599 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 600 | : __tree_(_VSTD::move(__s.__tree_)) {} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 601 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 602 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 603 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 604 | explicit set(const allocator_type& __a) |
| 605 | : __tree_(__a) {} |
| 606 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 607 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 608 | set(const set& __s, const allocator_type& __a) |
| 609 | : __tree_(__s.__tree_.value_comp(), __a) |
| 610 | { |
| 611 | insert(__s.begin(), __s.end()); |
| 612 | } |
| 613 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 614 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 615 | set(set&& __s, const allocator_type& __a); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 616 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 617 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 618 | set(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 619 | : __tree_(__comp) |
| 620 | { |
| 621 | insert(__il.begin(), __il.end()); |
| 622 | } |
| 623 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 624 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 625 | set(initializer_list<value_type> __il, const value_compare& __comp, |
| 626 | const allocator_type& __a) |
| 627 | : __tree_(__comp, __a) |
| 628 | { |
| 629 | insert(__il.begin(), __il.end()); |
| 630 | } |
| 631 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 632 | #if _LIBCPP_STD_VER > 11 |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 633 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 634 | set(initializer_list<value_type> __il, const allocator_type& __a) |
| 635 | : set(__il, key_compare(), __a) {} |
| 636 | #endif |
| 637 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 638 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 639 | set& operator=(initializer_list<value_type> __il) |
| 640 | { |
| 641 | __tree_.__assign_unique(__il.begin(), __il.end()); |
| 642 | return *this; |
| 643 | } |
| 644 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 645 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 646 | set& operator=(set&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 647 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 648 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 649 | __tree_ = _VSTD::move(__s.__tree_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 650 | return *this; |
| 651 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 652 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 653 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 654 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | 69c42c0 | 2019-04-11 16:14:56 +0000 | [diff] [blame] | 655 | ~set() { |
| 656 | static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
| 657 | } |
| 658 | |
| 659 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 660 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 661 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 662 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 663 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 664 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 665 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 666 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 667 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 668 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 669 | reverse_iterator rbegin() _NOEXCEPT |
| 670 | {return reverse_iterator(end());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 671 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 672 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 673 | {return const_reverse_iterator(end());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 674 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 675 | reverse_iterator rend() _NOEXCEPT |
| 676 | {return reverse_iterator(begin());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 677 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 678 | const_reverse_iterator rend() const _NOEXCEPT |
| 679 | {return const_reverse_iterator(begin());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 680 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 681 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 682 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 683 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 684 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 685 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 686 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 687 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 688 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 689 | |
Marshall Clow | 425f575 | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 690 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 691 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 692 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 693 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 694 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 695 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 696 | |
| 697 | // modifiers: |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 698 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 699 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 700 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 701 | pair<iterator, bool> emplace(_Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 702 | {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 703 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 704 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 705 | iterator emplace_hint(const_iterator __p, _Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 706 | {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 707 | #endif // _LIBCPP_CXX03_LANG |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 708 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 709 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 710 | pair<iterator,bool> insert(const value_type& __v) |
| 711 | {return __tree_.__insert_unique(__v);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 712 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 713 | iterator insert(const_iterator __p, const value_type& __v) |
| 714 | {return __tree_.__insert_unique(__p, __v);} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 715 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 716 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 717 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 718 | void insert(_InputIterator __f, _InputIterator __l) |
| 719 | { |
| 720 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 721 | __tree_.__insert_unique(__e, *__f); |
| 722 | } |
| 723 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 724 | #ifndef _LIBCPP_CXX03_LANG |
| 725 | _LIBCPP_INLINE_VISIBILITY |
| 726 | pair<iterator,bool> insert(value_type&& __v) |
| 727 | {return __tree_.__insert_unique(_VSTD::move(__v));} |
| 728 | |
| 729 | _LIBCPP_INLINE_VISIBILITY |
| 730 | iterator insert(const_iterator __p, value_type&& __v) |
| 731 | {return __tree_.__insert_unique(__p, _VSTD::move(__v));} |
| 732 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 733 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 734 | void insert(initializer_list<value_type> __il) |
| 735 | {insert(__il.begin(), __il.end());} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 736 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 737 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 738 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 739 | iterator erase(const_iterator __p) {return __tree_.erase(__p);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 740 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 741 | size_type erase(const key_type& __k) |
| 742 | {return __tree_.__erase_unique(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 743 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 744 | iterator erase(const_iterator __f, const_iterator __l) |
| 745 | {return __tree_.erase(__f, __l);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 746 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 747 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 748 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 749 | #if _LIBCPP_STD_VER > 14 |
| 750 | _LIBCPP_INLINE_VISIBILITY |
| 751 | insert_return_type insert(node_type&& __nh) |
| 752 | { |
| 753 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 754 | "node_type with incompatible allocator passed to set::insert()"); |
| 755 | return __tree_.template __node_handle_insert_unique< |
| 756 | node_type, insert_return_type>(_VSTD::move(__nh)); |
| 757 | } |
| 758 | _LIBCPP_INLINE_VISIBILITY |
| 759 | iterator insert(const_iterator __hint, node_type&& __nh) |
| 760 | { |
| 761 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 762 | "node_type with incompatible allocator passed to set::insert()"); |
| 763 | return __tree_.template __node_handle_insert_unique<node_type>( |
| 764 | __hint, _VSTD::move(__nh)); |
| 765 | } |
| 766 | _LIBCPP_INLINE_VISIBILITY |
| 767 | node_type extract(key_type const& __key) |
| 768 | { |
| 769 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 770 | } |
| 771 | _LIBCPP_INLINE_VISIBILITY |
| 772 | node_type extract(const_iterator __it) |
| 773 | { |
| 774 | return __tree_.template __node_handle_extract<node_type>(__it); |
| 775 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 776 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 777 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 778 | void merge(set<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 779 | { |
| 780 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 781 | "merging container with incompatible allocator"); |
| 782 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 783 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 784 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 785 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 786 | void merge(set<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 787 | { |
| 788 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 789 | "merging container with incompatible allocator"); |
| 790 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 791 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 792 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 793 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 794 | void merge(multiset<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 795 | { |
| 796 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 797 | "merging container with incompatible allocator"); |
| 798 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 799 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 800 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 801 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 802 | void merge(multiset<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 803 | { |
| 804 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 805 | "merging container with incompatible allocator"); |
| 806 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 807 | } |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 808 | #endif |
| 809 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 810 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 811 | void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 812 | {__tree_.swap(__s.__tree_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 813 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 814 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 815 | allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 816 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 817 | key_compare key_comp() const {return __tree_.value_comp();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 818 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 819 | value_compare value_comp() const {return __tree_.value_comp();} |
| 820 | |
| 821 | // set operations: |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 822 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 823 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 824 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 825 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 826 | #if _LIBCPP_STD_VER > 11 |
| 827 | template <typename _K2> |
| 828 | _LIBCPP_INLINE_VISIBILITY |
| 829 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 830 | find(const _K2& __k) {return __tree_.find(__k);} |
| 831 | template <typename _K2> |
| 832 | _LIBCPP_INLINE_VISIBILITY |
| 833 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 834 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 835 | #endif |
| 836 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 837 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 838 | size_type count(const key_type& __k) const |
| 839 | {return __tree_.__count_unique(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 840 | #if _LIBCPP_STD_VER > 11 |
| 841 | template <typename _K2> |
| 842 | _LIBCPP_INLINE_VISIBILITY |
| 843 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 844 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 845 | #endif |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 846 | |
| 847 | #if _LIBCPP_STD_VER > 17 |
| 848 | _LIBCPP_INLINE_VISIBILITY |
| 849 | bool contains(const key_type& __k) const {return find(__k) != end();} |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 850 | template <typename _K2> |
| 851 | _LIBCPP_INLINE_VISIBILITY |
| 852 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 853 | contains(const _K2& __k) const { return find(__k) != end(); } |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 854 | #endif // _LIBCPP_STD_VER > 17 |
| 855 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 856 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 857 | iterator lower_bound(const key_type& __k) |
| 858 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 859 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 860 | const_iterator lower_bound(const key_type& __k) const |
| 861 | {return __tree_.lower_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 862 | #if _LIBCPP_STD_VER > 11 |
| 863 | template <typename _K2> |
| 864 | _LIBCPP_INLINE_VISIBILITY |
| 865 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 866 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 867 | |
| 868 | template <typename _K2> |
| 869 | _LIBCPP_INLINE_VISIBILITY |
| 870 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 871 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 872 | #endif |
| 873 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 874 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 875 | iterator upper_bound(const key_type& __k) |
| 876 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 877 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 878 | const_iterator upper_bound(const key_type& __k) const |
| 879 | {return __tree_.upper_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 880 | #if _LIBCPP_STD_VER > 11 |
| 881 | template <typename _K2> |
| 882 | _LIBCPP_INLINE_VISIBILITY |
| 883 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 884 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 885 | template <typename _K2> |
| 886 | _LIBCPP_INLINE_VISIBILITY |
| 887 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 888 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 889 | #endif |
| 890 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 891 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 892 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 893 | {return __tree_.__equal_range_unique(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 894 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 895 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 896 | {return __tree_.__equal_range_unique(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 897 | #if _LIBCPP_STD_VER > 11 |
| 898 | template <typename _K2> |
| 899 | _LIBCPP_INLINE_VISIBILITY |
| 900 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 901 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 902 | template <typename _K2> |
| 903 | _LIBCPP_INLINE_VISIBILITY |
| 904 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 905 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 906 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 907 | }; |
| 908 | |
Louis Dionne | d59f8a5 | 2021-08-17 11:59:07 -0400 | [diff] [blame] | 909 | #if _LIBCPP_STD_VER >= 17 |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 910 | template<class _InputIterator, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 911 | class _Compare = less<__iter_value_type<_InputIterator>>, |
| 912 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 913 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 914 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, |
| 915 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 916 | set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 917 | -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 918 | |
| 919 | template<class _Key, class _Compare = less<_Key>, |
| 920 | class _Allocator = allocator<_Key>, |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 921 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, |
| 922 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 923 | set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 924 | -> set<_Key, _Compare, _Allocator>; |
| 925 | |
| 926 | template<class _InputIterator, class _Allocator, |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 927 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 928 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 929 | set(_InputIterator, _InputIterator, _Allocator) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 930 | -> set<__iter_value_type<_InputIterator>, |
| 931 | less<__iter_value_type<_InputIterator>>, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 932 | |
| 933 | template<class _Key, class _Allocator, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 934 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 935 | set(initializer_list<_Key>, _Allocator) |
| 936 | -> set<_Key, less<_Key>, _Allocator>; |
| 937 | #endif |
| 938 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 939 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 940 | |
| 941 | template <class _Key, class _Compare, class _Allocator> |
| 942 | set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 943 | : __tree_(_VSTD::move(__s.__tree_), __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 944 | { |
| 945 | if (__a != __s.get_allocator()) |
| 946 | { |
| 947 | const_iterator __e = cend(); |
| 948 | while (!__s.empty()) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 949 | insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 950 | } |
| 951 | } |
| 952 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 953 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 954 | |
| 955 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 956 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 957 | bool |
| 958 | operator==(const set<_Key, _Compare, _Allocator>& __x, |
| 959 | const set<_Key, _Compare, _Allocator>& __y) |
| 960 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 961 | return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 965 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 966 | bool |
| 967 | operator< (const set<_Key, _Compare, _Allocator>& __x, |
| 968 | const set<_Key, _Compare, _Allocator>& __y) |
| 969 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 970 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 971 | } |
| 972 | |
| 973 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 974 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 975 | bool |
| 976 | operator!=(const set<_Key, _Compare, _Allocator>& __x, |
| 977 | const set<_Key, _Compare, _Allocator>& __y) |
| 978 | { |
| 979 | return !(__x == __y); |
| 980 | } |
| 981 | |
| 982 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 983 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 984 | bool |
| 985 | operator> (const set<_Key, _Compare, _Allocator>& __x, |
| 986 | const set<_Key, _Compare, _Allocator>& __y) |
| 987 | { |
| 988 | return __y < __x; |
| 989 | } |
| 990 | |
| 991 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 992 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 993 | bool |
| 994 | operator>=(const set<_Key, _Compare, _Allocator>& __x, |
| 995 | const set<_Key, _Compare, _Allocator>& __y) |
| 996 | { |
| 997 | return !(__x < __y); |
| 998 | } |
| 999 | |
| 1000 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1001 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1002 | bool |
| 1003 | operator<=(const set<_Key, _Compare, _Allocator>& __x, |
| 1004 | const set<_Key, _Compare, _Allocator>& __y) |
| 1005 | { |
| 1006 | return !(__y < __x); |
| 1007 | } |
| 1008 | |
| 1009 | // specialized algorithms: |
| 1010 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1011 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1012 | void |
| 1013 | swap(set<_Key, _Compare, _Allocator>& __x, |
| 1014 | set<_Key, _Compare, _Allocator>& __y) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1015 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1016 | { |
| 1017 | __x.swap(__y); |
| 1018 | } |
| 1019 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 1020 | #if _LIBCPP_STD_VER > 17 |
| 1021 | template <class _Key, class _Compare, class _Allocator, class _Predicate> |
| 1022 | inline _LIBCPP_INLINE_VISIBILITY |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 1023 | typename set<_Key, _Compare, _Allocator>::size_type |
| 1024 | erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 1025 | return _VSTD::__libcpp_erase_if_container(__c, __pred); |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 1026 | } |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 1027 | #endif |
| 1028 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1029 | template <class _Key, class _Compare = less<_Key>, |
| 1030 | class _Allocator = allocator<_Key> > |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1031 | class _LIBCPP_TEMPLATE_VIS multiset |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1032 | { |
| 1033 | public: |
| 1034 | // types: |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 1035 | typedef _Key key_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1036 | typedef key_type value_type; |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 1037 | typedef __identity_t<_Compare> key_compare; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1038 | typedef key_compare value_compare; |
Arthur O'Dwyer | 6a752e1 | 2021-03-03 11:10:49 -0500 | [diff] [blame] | 1039 | typedef __identity_t<_Allocator> allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1040 | typedef value_type& reference; |
| 1041 | typedef const value_type& const_reference; |
| 1042 | |
Marshall Clow | 5128cf3 | 2015-11-26 01:24:04 +0000 | [diff] [blame] | 1043 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 1044 | "Allocator::value_type must be same type as value_type"); |
| 1045 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1046 | private: |
| 1047 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 1048 | typedef allocator_traits<allocator_type> __alloc_traits; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1049 | |
| 1050 | __base __tree_; |
| 1051 | |
| 1052 | public: |
| 1053 | typedef typename __base::pointer pointer; |
| 1054 | typedef typename __base::const_pointer const_pointer; |
| 1055 | typedef typename __base::size_type size_type; |
| 1056 | typedef typename __base::difference_type difference_type; |
| 1057 | typedef typename __base::const_iterator iterator; |
| 1058 | typedef typename __base::const_iterator const_iterator; |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1059 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 1060 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1061 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1062 | #if _LIBCPP_STD_VER > 14 |
| 1063 | typedef __set_node_handle<typename __base::__node, allocator_type> node_type; |
| 1064 | #endif |
| 1065 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1066 | template <class _Key2, class _Compare2, class _Alloc2> |
| 1067 | friend class _LIBCPP_TEMPLATE_VIS set; |
| 1068 | template <class _Key2, class _Compare2, class _Alloc2> |
| 1069 | friend class _LIBCPP_TEMPLATE_VIS multiset; |
| 1070 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1071 | // construct/copy/destroy: |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1072 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 1073 | multiset() |
| 1074 | _NOEXCEPT_( |
| 1075 | is_nothrow_default_constructible<allocator_type>::value && |
| 1076 | is_nothrow_default_constructible<key_compare>::value && |
| 1077 | is_nothrow_copy_constructible<key_compare>::value) |
| 1078 | : __tree_(value_compare()) {} |
| 1079 | |
| 1080 | _LIBCPP_INLINE_VISIBILITY |
| 1081 | explicit multiset(const value_compare& __comp) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1082 | _NOEXCEPT_( |
| 1083 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1084 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1085 | : __tree_(__comp) {} |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 1086 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1087 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7ed23a7 | 2014-03-05 19:06:20 +0000 | [diff] [blame] | 1088 | explicit multiset(const value_compare& __comp, const allocator_type& __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1089 | : __tree_(__comp, __a) {} |
| 1090 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1091 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1092 | multiset(_InputIterator __f, _InputIterator __l, |
| 1093 | const value_compare& __comp = value_compare()) |
| 1094 | : __tree_(__comp) |
| 1095 | { |
| 1096 | insert(__f, __l); |
| 1097 | } |
| 1098 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1099 | #if _LIBCPP_STD_VER > 11 |
| 1100 | template <class _InputIterator> |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1101 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1102 | multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 1103 | : multiset(__f, __l, key_compare(), __a) {} |
| 1104 | #endif |
| 1105 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1106 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1107 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1108 | multiset(_InputIterator __f, _InputIterator __l, |
| 1109 | const value_compare& __comp, const allocator_type& __a) |
| 1110 | : __tree_(__comp, __a) |
| 1111 | { |
| 1112 | insert(__f, __l); |
| 1113 | } |
| 1114 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1115 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1116 | multiset(const multiset& __s) |
| 1117 | : __tree_(__s.__tree_.value_comp(), |
| 1118 | __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc())) |
| 1119 | { |
| 1120 | insert(__s.begin(), __s.end()); |
| 1121 | } |
| 1122 | |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1123 | _LIBCPP_INLINE_VISIBILITY |
| 1124 | multiset& operator=(const multiset& __s) |
| 1125 | { |
| 1126 | __tree_ = __s.__tree_; |
| 1127 | return *this; |
| 1128 | } |
| 1129 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1130 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1131 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1132 | multiset(multiset&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1133 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1134 | : __tree_(_VSTD::move(__s.__tree_)) {} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1135 | |
| 1136 | multiset(multiset&& __s, const allocator_type& __a); |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1137 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1138 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1139 | explicit multiset(const allocator_type& __a) |
| 1140 | : __tree_(__a) {} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1141 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1142 | multiset(const multiset& __s, const allocator_type& __a) |
| 1143 | : __tree_(__s.__tree_.value_comp(), __a) |
| 1144 | { |
| 1145 | insert(__s.begin(), __s.end()); |
| 1146 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1147 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1148 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1149 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1150 | multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 1151 | : __tree_(__comp) |
| 1152 | { |
| 1153 | insert(__il.begin(), __il.end()); |
| 1154 | } |
| 1155 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1156 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1157 | multiset(initializer_list<value_type> __il, const value_compare& __comp, |
| 1158 | const allocator_type& __a) |
| 1159 | : __tree_(__comp, __a) |
| 1160 | { |
| 1161 | insert(__il.begin(), __il.end()); |
| 1162 | } |
| 1163 | |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1164 | #if _LIBCPP_STD_VER > 11 |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1165 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 631788a | 2013-09-11 00:06:45 +0000 | [diff] [blame] | 1166 | multiset(initializer_list<value_type> __il, const allocator_type& __a) |
| 1167 | : multiset(__il, key_compare(), __a) {} |
| 1168 | #endif |
| 1169 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1170 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1171 | multiset& operator=(initializer_list<value_type> __il) |
| 1172 | { |
| 1173 | __tree_.__assign_multi(__il.begin(), __il.end()); |
| 1174 | return *this; |
| 1175 | } |
| 1176 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1177 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1178 | multiset& operator=(multiset&& __s) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1179 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1180 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1181 | __tree_ = _VSTD::move(__s.__tree_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1182 | return *this; |
| 1183 | } |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1184 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1185 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1186 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | 69c42c0 | 2019-04-11 16:14:56 +0000 | [diff] [blame] | 1187 | ~multiset() { |
| 1188 | static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
| 1189 | } |
| 1190 | |
| 1191 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1192 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1193 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1194 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1195 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1196 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1197 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1198 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1199 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1200 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1201 | reverse_iterator rbegin() _NOEXCEPT |
| 1202 | {return reverse_iterator(end());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1203 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1204 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 1205 | {return const_reverse_iterator(end());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1206 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1207 | reverse_iterator rend() _NOEXCEPT |
| 1208 | {return reverse_iterator(begin());} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1209 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1210 | const_reverse_iterator rend() const _NOEXCEPT |
| 1211 | {return const_reverse_iterator(begin());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1212 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1213 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1214 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1215 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1216 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1217 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1218 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1219 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1220 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1221 | |
Marshall Clow | 425f575 | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 1222 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1223 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1224 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1225 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1226 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1227 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1228 | |
| 1229 | // modifiers: |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1230 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1231 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1232 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1233 | iterator emplace(_Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1234 | {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1235 | template <class... _Args> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1236 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1237 | iterator emplace_hint(const_iterator __p, _Args&&... __args) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1238 | {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1239 | #endif // _LIBCPP_CXX03_LANG |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1240 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1241 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1242 | iterator insert(const value_type& __v) |
| 1243 | {return __tree_.__insert_multi(__v);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1244 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1245 | iterator insert(const_iterator __p, const value_type& __v) |
| 1246 | {return __tree_.__insert_multi(__p, __v);} |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1247 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1248 | template <class _InputIterator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1249 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1250 | void insert(_InputIterator __f, _InputIterator __l) |
| 1251 | { |
| 1252 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 1253 | __tree_.__insert_multi(__e, *__f); |
| 1254 | } |
| 1255 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1256 | #ifndef _LIBCPP_CXX03_LANG |
| 1257 | _LIBCPP_INLINE_VISIBILITY |
| 1258 | iterator insert(value_type&& __v) |
| 1259 | {return __tree_.__insert_multi(_VSTD::move(__v));} |
| 1260 | |
| 1261 | _LIBCPP_INLINE_VISIBILITY |
| 1262 | iterator insert(const_iterator __p, value_type&& __v) |
| 1263 | {return __tree_.__insert_multi(__p, _VSTD::move(__v));} |
| 1264 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1265 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1266 | void insert(initializer_list<value_type> __il) |
| 1267 | {insert(__il.begin(), __il.end());} |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1268 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1269 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1270 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1271 | iterator erase(const_iterator __p) {return __tree_.erase(__p);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1272 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1273 | size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1274 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1275 | iterator erase(const_iterator __f, const_iterator __l) |
| 1276 | {return __tree_.erase(__f, __l);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1277 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1278 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1279 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1280 | #if _LIBCPP_STD_VER > 14 |
| 1281 | _LIBCPP_INLINE_VISIBILITY |
| 1282 | iterator insert(node_type&& __nh) |
| 1283 | { |
| 1284 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1285 | "node_type with incompatible allocator passed to multiset::insert()"); |
| 1286 | return __tree_.template __node_handle_insert_multi<node_type>( |
| 1287 | _VSTD::move(__nh)); |
| 1288 | } |
| 1289 | _LIBCPP_INLINE_VISIBILITY |
| 1290 | iterator insert(const_iterator __hint, node_type&& __nh) |
| 1291 | { |
| 1292 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1293 | "node_type with incompatible allocator passed to multiset::insert()"); |
| 1294 | return __tree_.template __node_handle_insert_multi<node_type>( |
| 1295 | __hint, _VSTD::move(__nh)); |
| 1296 | } |
| 1297 | _LIBCPP_INLINE_VISIBILITY |
| 1298 | node_type extract(key_type const& __key) |
| 1299 | { |
| 1300 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 1301 | } |
| 1302 | _LIBCPP_INLINE_VISIBILITY |
| 1303 | node_type extract(const_iterator __it) |
| 1304 | { |
| 1305 | return __tree_.template __node_handle_extract<node_type>(__it); |
| 1306 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1307 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1308 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1309 | void merge(multiset<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1310 | { |
| 1311 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1312 | "merging container with incompatible allocator"); |
| 1313 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1314 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1315 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1316 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1317 | void merge(multiset<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1318 | { |
| 1319 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1320 | "merging container with incompatible allocator"); |
| 1321 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1322 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1323 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1324 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1325 | void merge(set<key_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1326 | { |
| 1327 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1328 | "merging container with incompatible allocator"); |
| 1329 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1330 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1331 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1332 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1333 | void merge(set<key_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1334 | { |
| 1335 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1336 | "merging container with incompatible allocator"); |
| 1337 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1338 | } |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1339 | #endif |
| 1340 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1341 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1342 | void swap(multiset& __s) |
| 1343 | _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 1344 | {__tree_.swap(__s.__tree_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1345 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1346 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1347 | allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1348 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1349 | key_compare key_comp() const {return __tree_.value_comp();} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1350 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1351 | value_compare value_comp() const {return __tree_.value_comp();} |
| 1352 | |
| 1353 | // set operations: |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1354 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1355 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1356 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1357 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1358 | #if _LIBCPP_STD_VER > 11 |
| 1359 | template <typename _K2> |
| 1360 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1361 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1362 | find(const _K2& __k) {return __tree_.find(__k);} |
| 1363 | template <typename _K2> |
| 1364 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1365 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1366 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 1367 | #endif |
| 1368 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1369 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1370 | size_type count(const key_type& __k) const |
| 1371 | {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 1372 | #if _LIBCPP_STD_VER > 11 |
| 1373 | template <typename _K2> |
| 1374 | _LIBCPP_INLINE_VISIBILITY |
| 1375 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
Marshall Clow | 5571bcd | 2018-01-07 17:39:57 +0000 | [diff] [blame] | 1376 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 1377 | #endif |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1378 | |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 1379 | #if _LIBCPP_STD_VER > 17 |
| 1380 | _LIBCPP_INLINE_VISIBILITY |
| 1381 | bool contains(const key_type& __k) const {return find(__k) != end();} |
Marek Kurdej | d7e019e | 2021-04-13 17:10:55 +0200 | [diff] [blame] | 1382 | template <typename _K2> |
| 1383 | _LIBCPP_INLINE_VISIBILITY |
| 1384 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 1385 | contains(const _K2& __k) const { return find(__k) != end(); } |
Zoe Carver | 3ffbab1 | 2019-07-16 03:21:01 +0000 | [diff] [blame] | 1386 | #endif // _LIBCPP_STD_VER > 17 |
| 1387 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1388 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1389 | iterator lower_bound(const key_type& __k) |
| 1390 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1391 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1392 | const_iterator lower_bound(const key_type& __k) const |
| 1393 | {return __tree_.lower_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1394 | #if _LIBCPP_STD_VER > 11 |
| 1395 | template <typename _K2> |
| 1396 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1397 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1398 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 1399 | |
| 1400 | template <typename _K2> |
| 1401 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1402 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1403 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 1404 | #endif |
| 1405 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1406 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1407 | iterator upper_bound(const key_type& __k) |
| 1408 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1409 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1410 | const_iterator upper_bound(const key_type& __k) const |
| 1411 | {return __tree_.upper_bound(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1412 | #if _LIBCPP_STD_VER > 11 |
| 1413 | template <typename _K2> |
| 1414 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1415 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1416 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 1417 | template <typename _K2> |
| 1418 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1419 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1420 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 1421 | #endif |
| 1422 | |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1423 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1424 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 1425 | {return __tree_.__equal_range_multi(__k);} |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1426 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1427 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 1428 | {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1429 | #if _LIBCPP_STD_VER > 11 |
| 1430 | template <typename _K2> |
| 1431 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1432 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1433 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
| 1434 | template <typename _K2> |
| 1435 | _LIBCPP_INLINE_VISIBILITY |
Mark de Wever | 9d7aa7a | 2021-05-09 18:22:52 +0200 | [diff] [blame] | 1436 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
Marshall Clow | c015214 | 2013-08-13 01:11:06 +0000 | [diff] [blame] | 1437 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
| 1438 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1439 | }; |
| 1440 | |
Louis Dionne | d59f8a5 | 2021-08-17 11:59:07 -0400 | [diff] [blame] | 1441 | #if _LIBCPP_STD_VER >= 17 |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1442 | template<class _InputIterator, |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 1443 | class _Compare = less<__iter_value_type<_InputIterator>>, |
| 1444 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 1445 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 1446 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, |
| 1447 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1448 | multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 1449 | -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1450 | |
| 1451 | template<class _Key, class _Compare = less<_Key>, |
| 1452 | class _Allocator = allocator<_Key>, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 1453 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, |
| 1454 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1455 | multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1456 | -> multiset<_Key, _Compare, _Allocator>; |
| 1457 | |
| 1458 | template<class _InputIterator, class _Allocator, |
Konstantin Varlamov | 53b543c | 2021-11-09 09:21:02 -0800 | [diff] [blame] | 1459 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 1460 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1461 | multiset(_InputIterator, _InputIterator, _Allocator) |
Arthur O'Dwyer | 5622676 | 2021-03-03 23:02:20 -0500 | [diff] [blame] | 1462 | -> multiset<__iter_value_type<_InputIterator>, |
| 1463 | less<__iter_value_type<_InputIterator>>, _Allocator>; |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1464 | |
| 1465 | template<class _Key, class _Allocator, |
Louis Dionne | 2554716 | 2021-08-17 12:26:09 -0400 | [diff] [blame] | 1466 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
Louis Dionne | 27ecc15 | 2019-06-11 18:21:08 +0000 | [diff] [blame] | 1467 | multiset(initializer_list<_Key>, _Allocator) |
| 1468 | -> multiset<_Key, less<_Key>, _Allocator>; |
| 1469 | #endif |
| 1470 | |
Eric Fiselier | 615961b | 2017-04-18 20:58:03 +0000 | [diff] [blame] | 1471 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1472 | |
| 1473 | template <class _Key, class _Compare, class _Allocator> |
| 1474 | multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1475 | : __tree_(_VSTD::move(__s.__tree_), __a) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1476 | { |
| 1477 | if (__a != __s.get_allocator()) |
| 1478 | { |
| 1479 | const_iterator __e = cend(); |
| 1480 | while (!__s.empty()) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1481 | insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1482 | } |
| 1483 | } |
| 1484 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1485 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1486 | |
| 1487 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1488 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1489 | bool |
| 1490 | operator==(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1491 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1492 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1493 | return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1494 | } |
| 1495 | |
| 1496 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1497 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1498 | bool |
| 1499 | operator< (const multiset<_Key, _Compare, _Allocator>& __x, |
| 1500 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1501 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1502 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1503 | } |
| 1504 | |
| 1505 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1506 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1507 | bool |
| 1508 | operator!=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1509 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1510 | { |
| 1511 | return !(__x == __y); |
| 1512 | } |
| 1513 | |
| 1514 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1515 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1516 | bool |
| 1517 | operator> (const multiset<_Key, _Compare, _Allocator>& __x, |
| 1518 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1519 | { |
| 1520 | return __y < __x; |
| 1521 | } |
| 1522 | |
| 1523 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1524 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1525 | bool |
| 1526 | operator>=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1527 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1528 | { |
| 1529 | return !(__x < __y); |
| 1530 | } |
| 1531 | |
| 1532 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1533 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1534 | bool |
| 1535 | operator<=(const multiset<_Key, _Compare, _Allocator>& __x, |
| 1536 | const multiset<_Key, _Compare, _Allocator>& __y) |
| 1537 | { |
| 1538 | return !(__y < __x); |
| 1539 | } |
| 1540 | |
| 1541 | template <class _Key, class _Compare, class _Allocator> |
Howard Hinnant | 192cf03 | 2010-09-23 16:27:36 +0000 | [diff] [blame] | 1542 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1543 | void |
| 1544 | swap(multiset<_Key, _Compare, _Allocator>& __x, |
| 1545 | multiset<_Key, _Compare, _Allocator>& __y) |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 1546 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1547 | { |
| 1548 | __x.swap(__y); |
| 1549 | } |
| 1550 | |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 1551 | #if _LIBCPP_STD_VER > 17 |
| 1552 | template <class _Key, class _Compare, class _Allocator, class _Predicate> |
| 1553 | inline _LIBCPP_INLINE_VISIBILITY |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 1554 | typename multiset<_Key, _Compare, _Allocator>::size_type |
| 1555 | erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { |
Arthur O'Dwyer | b6738bd | 2021-03-21 16:53:09 -0400 | [diff] [blame] | 1556 | return _VSTD::__libcpp_erase_if_container(__c, __pred); |
Marek Kurdej | a98b141 | 2020-05-02 13:58:03 +0200 | [diff] [blame] | 1557 | } |
Marshall Clow | 29b53f2 | 2018-12-14 18:49:35 +0000 | [diff] [blame] | 1558 | #endif |
| 1559 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1560 | _LIBCPP_END_NAMESPACE_STD |
| 1561 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1562 | #endif // _LIBCPP_SET |