Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===----------------------------- map ------------------------------------===// |
| 3 | // |
Howard Hinnant | c566dc3 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | ee11c31 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_MAP |
| 12 | #define _LIBCPP_MAP |
| 13 | |
| 14 | /* |
| 15 | |
| 16 | map synopsis |
| 17 | |
| 18 | namespace std |
| 19 | { |
| 20 | |
| 21 | template <class Key, class T, class Compare = less<Key>, |
| 22 | class Allocator = allocator<pair<const Key, T>>> |
| 23 | class map |
| 24 | { |
| 25 | public: |
| 26 | // types: |
| 27 | typedef Key key_type; |
| 28 | typedef T mapped_type; |
| 29 | typedef pair<const key_type, mapped_type> value_type; |
| 30 | typedef Compare key_compare; |
| 31 | typedef Allocator allocator_type; |
| 32 | typedef typename allocator_type::reference reference; |
| 33 | typedef typename allocator_type::const_reference const_reference; |
| 34 | typedef typename allocator_type::pointer pointer; |
| 35 | typedef typename allocator_type::const_pointer const_pointer; |
| 36 | typedef typename allocator_type::size_type size_type; |
| 37 | typedef typename allocator_type::difference_type difference_type; |
| 38 | |
| 39 | typedef implementation-defined iterator; |
| 40 | typedef implementation-defined const_iterator; |
| 41 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 42 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 43 | typedef unspecified node_type; // C++17 |
| 44 | typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | |
| 46 | class value_compare |
| 47 | : public binary_function<value_type, value_type, bool> |
| 48 | { |
| 49 | friend class map; |
| 50 | protected: |
| 51 | key_compare comp; |
| 52 | |
| 53 | value_compare(key_compare c); |
| 54 | public: |
| 55 | bool operator()(const value_type& x, const value_type& y) const; |
| 56 | }; |
| 57 | |
| 58 | // construct/copy/destroy: |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 59 | map() |
| 60 | noexcept( |
| 61 | is_nothrow_default_constructible<allocator_type>::value && |
| 62 | is_nothrow_default_constructible<key_compare>::value && |
| 63 | is_nothrow_copy_constructible<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 64 | explicit map(const key_compare& comp); |
| 65 | map(const key_compare& comp, const allocator_type& a); |
| 66 | template <class InputIterator> |
| 67 | map(InputIterator first, InputIterator last, |
| 68 | const key_compare& comp = key_compare()); |
| 69 | template <class InputIterator> |
| 70 | map(InputIterator first, InputIterator last, |
| 71 | const key_compare& comp, const allocator_type& a); |
| 72 | map(const map& m); |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 73 | map(map&& m) |
| 74 | noexcept( |
| 75 | is_nothrow_move_constructible<allocator_type>::value && |
| 76 | is_nothrow_move_constructible<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 77 | explicit map(const allocator_type& a); |
| 78 | map(const map& m, const allocator_type& a); |
| 79 | map(map&& m, const allocator_type& a); |
| 80 | map(initializer_list<value_type> il, const key_compare& comp = key_compare()); |
| 81 | map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 82 | template <class InputIterator> |
| 83 | map(InputIterator first, InputIterator last, const allocator_type& a) |
| 84 | : map(first, last, Compare(), a) {} // C++14 |
| 85 | map(initializer_list<value_type> il, const allocator_type& a) |
| 86 | : map(il, Compare(), a) {} // C++14 |
| 87 | ~map(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 88 | |
| 89 | map& operator=(const map& m); |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 90 | map& operator=(map&& m) |
| 91 | noexcept( |
| 92 | allocator_type::propagate_on_container_move_assignment::value && |
| 93 | is_nothrow_move_assignable<allocator_type>::value && |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 94 | is_nothrow_move_assignable<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 95 | map& operator=(initializer_list<value_type> il); |
| 96 | |
| 97 | // iterators: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 98 | iterator begin() noexcept; |
| 99 | const_iterator begin() const noexcept; |
| 100 | iterator end() noexcept; |
| 101 | const_iterator end() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 102 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 103 | reverse_iterator rbegin() noexcept; |
| 104 | const_reverse_iterator rbegin() const noexcept; |
| 105 | reverse_iterator rend() noexcept; |
| 106 | const_reverse_iterator rend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 107 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 108 | const_iterator cbegin() const noexcept; |
| 109 | const_iterator cend() const noexcept; |
| 110 | const_reverse_iterator crbegin() const noexcept; |
| 111 | const_reverse_iterator crend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 112 | |
| 113 | // capacity: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 114 | bool empty() const noexcept; |
| 115 | size_type size() const noexcept; |
| 116 | size_type max_size() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 117 | |
| 118 | // element access: |
| 119 | mapped_type& operator[](const key_type& k); |
| 120 | mapped_type& operator[](key_type&& k); |
| 121 | |
| 122 | mapped_type& at(const key_type& k); |
| 123 | const mapped_type& at(const key_type& k) const; |
| 124 | |
| 125 | // modifiers: |
| 126 | template <class... Args> |
| 127 | pair<iterator, bool> emplace(Args&&... args); |
| 128 | template <class... Args> |
| 129 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 130 | pair<iterator, bool> insert(const value_type& v); |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 131 | pair<iterator, bool> insert( value_type&& v); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 132 | template <class P> |
| 133 | pair<iterator, bool> insert(P&& p); |
| 134 | iterator insert(const_iterator position, const value_type& v); |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 135 | iterator insert(const_iterator position, value_type&& v); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 136 | template <class P> |
| 137 | iterator insert(const_iterator position, P&& p); |
| 138 | template <class InputIterator> |
| 139 | void insert(InputIterator first, InputIterator last); |
| 140 | void insert(initializer_list<value_type> il); |
| 141 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 142 | node_type extract(const_iterator position); // C++17 |
| 143 | node_type extract(const key_type& x); // C++17 |
| 144 | insert_return_type insert(node_type&& nh); // C++17 |
| 145 | iterator insert(const_iterator hint, node_type&& nh); // C++17 |
| 146 | |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 147 | template <class... Args> |
| 148 | pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17 |
| 149 | template <class... Args> |
| 150 | pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17 |
| 151 | template <class... Args> |
| 152 | iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 |
| 153 | template <class... Args> |
| 154 | iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 |
| 155 | template <class M> |
| 156 | pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17 |
| 157 | template <class M> |
| 158 | pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17 |
| 159 | template <class M> |
| 160 | iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 |
| 161 | template <class M> |
| 162 | iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 |
| 163 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 164 | iterator erase(const_iterator position); |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 165 | iterator erase(iterator position); // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 166 | size_type erase(const key_type& k); |
| 167 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 168 | void clear() noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 169 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 170 | template<class C2> |
| 171 | void merge(map<Key, T, C2, Allocator>& source); // C++17 |
| 172 | template<class C2> |
| 173 | void merge(map<Key, T, C2, Allocator>&& source); // C++17 |
| 174 | template<class C2> |
| 175 | void merge(multimap<Key, T, C2, Allocator>& source); // C++17 |
| 176 | template<class C2> |
| 177 | void merge(multimap<Key, T, C2, Allocator>&& source); // C++17 |
| 178 | |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 179 | void swap(map& m) |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 180 | noexcept(allocator_traits<allocator_type>::is_always_equal::value && |
Eric Fiselier | 6bfed25 | 2016-04-21 23:38:59 +0000 | [diff] [blame] | 181 | is_nothrow_swappable<key_compare>::value); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 182 | |
| 183 | // observers: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 184 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 185 | key_compare key_comp() const; |
| 186 | value_compare value_comp() const; |
| 187 | |
| 188 | // map operations: |
| 189 | iterator find(const key_type& k); |
| 190 | const_iterator find(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 191 | template<typename K> |
| 192 | iterator find(const K& x); // C++14 |
| 193 | template<typename K> |
| 194 | const_iterator find(const K& x) const; // C++14 |
| 195 | template<typename K> |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 196 | size_type count(const K& x) const; // C++14 |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 197 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 198 | size_type count(const key_type& k) const; |
| 199 | iterator lower_bound(const key_type& k); |
| 200 | const_iterator lower_bound(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 201 | template<typename K> |
| 202 | iterator lower_bound(const K& x); // C++14 |
| 203 | template<typename K> |
| 204 | const_iterator lower_bound(const K& x) const; // C++14 |
| 205 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 206 | iterator upper_bound(const key_type& k); |
| 207 | const_iterator upper_bound(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 208 | template<typename K> |
| 209 | iterator upper_bound(const K& x); // C++14 |
| 210 | template<typename K> |
| 211 | const_iterator upper_bound(const K& x) const; // C++14 |
| 212 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 213 | pair<iterator,iterator> equal_range(const key_type& k); |
| 214 | pair<const_iterator,const_iterator> equal_range(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 215 | template<typename K> |
| 216 | pair<iterator,iterator> equal_range(const K& x); // C++14 |
| 217 | template<typename K> |
| 218 | 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] | 219 | }; |
| 220 | |
| 221 | template <class Key, class T, class Compare, class Allocator> |
| 222 | bool |
| 223 | operator==(const map<Key, T, Compare, Allocator>& x, |
| 224 | const map<Key, T, Compare, Allocator>& y); |
| 225 | |
| 226 | template <class Key, class T, class Compare, class Allocator> |
| 227 | bool |
| 228 | operator< (const map<Key, T, Compare, Allocator>& x, |
| 229 | const map<Key, T, Compare, Allocator>& y); |
| 230 | |
| 231 | template <class Key, class T, class Compare, class Allocator> |
| 232 | bool |
| 233 | operator!=(const map<Key, T, Compare, Allocator>& x, |
| 234 | const map<Key, T, Compare, Allocator>& y); |
| 235 | |
| 236 | template <class Key, class T, class Compare, class Allocator> |
| 237 | bool |
| 238 | operator> (const map<Key, T, Compare, Allocator>& x, |
| 239 | const map<Key, T, Compare, Allocator>& y); |
| 240 | |
| 241 | template <class Key, class T, class Compare, class Allocator> |
| 242 | bool |
| 243 | operator>=(const map<Key, T, Compare, Allocator>& x, |
| 244 | const map<Key, T, Compare, Allocator>& y); |
| 245 | |
| 246 | template <class Key, class T, class Compare, class Allocator> |
| 247 | bool |
| 248 | operator<=(const map<Key, T, Compare, Allocator>& x, |
| 249 | const map<Key, T, Compare, Allocator>& y); |
| 250 | |
| 251 | // specialized algorithms: |
| 252 | template <class Key, class T, class Compare, class Allocator> |
| 253 | void |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 254 | swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y) |
| 255 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 256 | |
| 257 | template <class Key, class T, class Compare = less<Key>, |
| 258 | class Allocator = allocator<pair<const Key, T>>> |
| 259 | class multimap |
| 260 | { |
| 261 | public: |
| 262 | // types: |
| 263 | typedef Key key_type; |
| 264 | typedef T mapped_type; |
| 265 | typedef pair<const key_type,mapped_type> value_type; |
| 266 | typedef Compare key_compare; |
| 267 | typedef Allocator allocator_type; |
| 268 | typedef typename allocator_type::reference reference; |
| 269 | typedef typename allocator_type::const_reference const_reference; |
| 270 | typedef typename allocator_type::size_type size_type; |
| 271 | typedef typename allocator_type::difference_type difference_type; |
| 272 | typedef typename allocator_type::pointer pointer; |
| 273 | typedef typename allocator_type::const_pointer const_pointer; |
| 274 | |
| 275 | typedef implementation-defined iterator; |
| 276 | typedef implementation-defined const_iterator; |
| 277 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 278 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 279 | typedef unspecified node_type; // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 280 | |
| 281 | class value_compare |
| 282 | : public binary_function<value_type,value_type,bool> |
| 283 | { |
| 284 | friend class multimap; |
| 285 | protected: |
| 286 | key_compare comp; |
| 287 | value_compare(key_compare c); |
| 288 | public: |
| 289 | bool operator()(const value_type& x, const value_type& y) const; |
| 290 | }; |
| 291 | |
| 292 | // construct/copy/destroy: |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 293 | multimap() |
| 294 | noexcept( |
| 295 | is_nothrow_default_constructible<allocator_type>::value && |
| 296 | is_nothrow_default_constructible<key_compare>::value && |
| 297 | is_nothrow_copy_constructible<key_compare>::value); |
| 298 | explicit multimap(const key_compare& comp); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 299 | multimap(const key_compare& comp, const allocator_type& a); |
| 300 | template <class InputIterator> |
| 301 | multimap(InputIterator first, InputIterator last, const key_compare& comp); |
| 302 | template <class InputIterator> |
| 303 | multimap(InputIterator first, InputIterator last, const key_compare& comp, |
| 304 | const allocator_type& a); |
| 305 | multimap(const multimap& m); |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 306 | multimap(multimap&& m) |
| 307 | noexcept( |
| 308 | is_nothrow_move_constructible<allocator_type>::value && |
| 309 | is_nothrow_move_constructible<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 310 | explicit multimap(const allocator_type& a); |
| 311 | multimap(const multimap& m, const allocator_type& a); |
| 312 | multimap(multimap&& m, const allocator_type& a); |
| 313 | multimap(initializer_list<value_type> il, const key_compare& comp = key_compare()); |
| 314 | multimap(initializer_list<value_type> il, const key_compare& comp, |
| 315 | const allocator_type& a); |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 316 | template <class InputIterator> |
| 317 | multimap(InputIterator first, InputIterator last, const allocator_type& a) |
| 318 | : multimap(first, last, Compare(), a) {} // C++14 |
| 319 | multimap(initializer_list<value_type> il, const allocator_type& a) |
| 320 | : multimap(il, Compare(), a) {} // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 321 | ~multimap(); |
| 322 | |
| 323 | multimap& operator=(const multimap& m); |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 324 | multimap& operator=(multimap&& m) |
| 325 | noexcept( |
| 326 | allocator_type::propagate_on_container_move_assignment::value && |
| 327 | is_nothrow_move_assignable<allocator_type>::value && |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 328 | is_nothrow_move_assignable<key_compare>::value); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 329 | multimap& operator=(initializer_list<value_type> il); |
| 330 | |
| 331 | // iterators: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 332 | iterator begin() noexcept; |
| 333 | const_iterator begin() const noexcept; |
| 334 | iterator end() noexcept; |
| 335 | const_iterator end() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 336 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 337 | reverse_iterator rbegin() noexcept; |
| 338 | const_reverse_iterator rbegin() const noexcept; |
| 339 | reverse_iterator rend() noexcept; |
| 340 | const_reverse_iterator rend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 341 | |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 342 | const_iterator cbegin() const noexcept; |
| 343 | const_iterator cend() const noexcept; |
| 344 | const_reverse_iterator crbegin() const noexcept; |
| 345 | const_reverse_iterator crend() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 346 | |
| 347 | // capacity: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 348 | bool empty() const noexcept; |
| 349 | size_type size() const noexcept; |
| 350 | size_type max_size() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 351 | |
| 352 | // modifiers: |
| 353 | template <class... Args> |
| 354 | iterator emplace(Args&&... args); |
| 355 | template <class... Args> |
| 356 | iterator emplace_hint(const_iterator position, Args&&... args); |
| 357 | iterator insert(const value_type& v); |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 358 | iterator insert( value_type&& v); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 359 | template <class P> |
| 360 | iterator insert(P&& p); |
| 361 | iterator insert(const_iterator position, const value_type& v); |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 362 | iterator insert(const_iterator position, value_type&& v); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 363 | template <class P> |
| 364 | iterator insert(const_iterator position, P&& p); |
| 365 | template <class InputIterator> |
| 366 | void insert(InputIterator first, InputIterator last); |
| 367 | void insert(initializer_list<value_type> il); |
| 368 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 369 | node_type extract(const_iterator position); // C++17 |
| 370 | node_type extract(const key_type& x); // C++17 |
| 371 | iterator insert(node_type&& nh); // C++17 |
| 372 | iterator insert(const_iterator hint, node_type&& nh); // C++17 |
| 373 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 374 | iterator erase(const_iterator position); |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 375 | iterator erase(iterator position); // C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 376 | size_type erase(const key_type& k); |
| 377 | iterator erase(const_iterator first, const_iterator last); |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 378 | void clear() noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 379 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 380 | template<class C2> |
| 381 | void merge(multimap<Key, T, C2, Allocator>& source); // C++17 |
| 382 | template<class C2> |
| 383 | void merge(multimap<Key, T, C2, Allocator>&& source); // C++17 |
| 384 | template<class C2> |
| 385 | void merge(map<Key, T, C2, Allocator>& source); // C++17 |
| 386 | template<class C2> |
| 387 | void merge(map<Key, T, C2, Allocator>&& source); // C++17 |
| 388 | |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 389 | void swap(multimap& m) |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 390 | noexcept(allocator_traits<allocator_type>::is_always_equal::value && |
Eric Fiselier | 6bfed25 | 2016-04-21 23:38:59 +0000 | [diff] [blame] | 391 | is_nothrow_swappable<key_compare>::value); // C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 392 | |
| 393 | // observers: |
Howard Hinnant | f95f4f5 | 2011-06-04 15:22:34 +0000 | [diff] [blame] | 394 | allocator_type get_allocator() const noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 395 | key_compare key_comp() const; |
| 396 | value_compare value_comp() const; |
| 397 | |
| 398 | // map operations: |
| 399 | iterator find(const key_type& k); |
| 400 | const_iterator find(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 401 | template<typename K> |
| 402 | iterator find(const K& x); // C++14 |
| 403 | template<typename K> |
| 404 | const_iterator find(const K& x) const; // C++14 |
| 405 | template<typename K> |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 406 | size_type count(const K& x) const; // C++14 |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 407 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 408 | size_type count(const key_type& k) const; |
| 409 | iterator lower_bound(const key_type& k); |
| 410 | const_iterator lower_bound(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 411 | template<typename K> |
| 412 | iterator lower_bound(const K& x); // C++14 |
| 413 | template<typename K> |
| 414 | const_iterator lower_bound(const K& x) const; // C++14 |
| 415 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 416 | iterator upper_bound(const key_type& k); |
| 417 | const_iterator upper_bound(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 418 | template<typename K> |
| 419 | iterator upper_bound(const K& x); // C++14 |
| 420 | template<typename K> |
| 421 | const_iterator upper_bound(const K& x) const; // C++14 |
| 422 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 423 | pair<iterator,iterator> equal_range(const key_type& k); |
| 424 | pair<const_iterator,const_iterator> equal_range(const key_type& k) const; |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 425 | template<typename K> |
| 426 | pair<iterator,iterator> equal_range(const K& x); // C++14 |
| 427 | template<typename K> |
| 428 | 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] | 429 | }; |
| 430 | |
| 431 | template <class Key, class T, class Compare, class Allocator> |
| 432 | bool |
| 433 | operator==(const multimap<Key, T, Compare, Allocator>& x, |
| 434 | const multimap<Key, T, Compare, Allocator>& y); |
| 435 | |
| 436 | template <class Key, class T, class Compare, class Allocator> |
| 437 | bool |
| 438 | operator< (const multimap<Key, T, Compare, Allocator>& x, |
| 439 | const multimap<Key, T, Compare, Allocator>& y); |
| 440 | |
| 441 | template <class Key, class T, class Compare, class Allocator> |
| 442 | bool |
| 443 | operator!=(const multimap<Key, T, Compare, Allocator>& x, |
| 444 | const multimap<Key, T, Compare, Allocator>& y); |
| 445 | |
| 446 | template <class Key, class T, class Compare, class Allocator> |
| 447 | bool |
| 448 | operator> (const multimap<Key, T, Compare, Allocator>& x, |
| 449 | const multimap<Key, T, Compare, Allocator>& y); |
| 450 | |
| 451 | template <class Key, class T, class Compare, class Allocator> |
| 452 | bool |
| 453 | operator>=(const multimap<Key, T, Compare, Allocator>& x, |
| 454 | const multimap<Key, T, Compare, Allocator>& y); |
| 455 | |
| 456 | template <class Key, class T, class Compare, class Allocator> |
| 457 | bool |
| 458 | operator<=(const multimap<Key, T, Compare, Allocator>& x, |
| 459 | const multimap<Key, T, Compare, Allocator>& y); |
| 460 | |
| 461 | // specialized algorithms: |
| 462 | template <class Key, class T, class Compare, class Allocator> |
| 463 | void |
| 464 | swap(multimap<Key, T, Compare, Allocator>& x, |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 465 | multimap<Key, T, Compare, Allocator>& y) |
| 466 | noexcept(noexcept(x.swap(y))); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 467 | |
| 468 | } // std |
| 469 | |
| 470 | */ |
| 471 | |
| 472 | #include <__config> |
| 473 | #include <__tree> |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 474 | #include <__node_handle> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 475 | #include <iterator> |
| 476 | #include <memory> |
| 477 | #include <utility> |
| 478 | #include <functional> |
| 479 | #include <initializer_list> |
Eric Fiselier | f739430 | 2015-06-13 07:08:02 +0000 | [diff] [blame] | 480 | #include <type_traits> |
Marshall Clow | 0a1e750 | 2018-09-12 19:41:40 +0000 | [diff] [blame] | 481 | #include <version> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 482 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 483 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 484 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 485 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 486 | |
| 487 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 488 | |
Louis Dionne | 878a3a8 | 2018-12-06 21:46:17 +0000 | [diff] [blame] | 489 | template <class _Key, class _CP, class _Compare, |
| 490 | bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 491 | class __map_value_compare |
| 492 | : private _Compare |
| 493 | { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 494 | public: |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 495 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 496 | __map_value_compare() |
| 497 | _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) |
| 498 | : _Compare() {} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 499 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 500 | __map_value_compare(_Compare c) |
| 501 | _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) |
| 502 | : _Compare(c) {} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 503 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 504 | const _Compare& key_comp() const _NOEXCEPT {return *this;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 505 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 506 | bool operator()(const _CP& __x, const _CP& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 507 | {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y.__get_value().first);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 508 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 509 | bool operator()(const _CP& __x, const _Key& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 510 | {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 511 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 512 | bool operator()(const _Key& __x, const _CP& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 513 | {return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);} |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 514 | void swap(__map_value_compare&__y) |
| 515 | _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) |
| 516 | { |
Eric Fiselier | 68b5f0b | 2017-04-13 00:34:24 +0000 | [diff] [blame] | 517 | using _VSTD::swap; |
| 518 | swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y)); |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 519 | } |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 520 | |
| 521 | #if _LIBCPP_STD_VER > 11 |
| 522 | template <typename _K2> |
| 523 | _LIBCPP_INLINE_VISIBILITY |
| 524 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 525 | operator () ( const _K2& __x, const _CP& __y ) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 526 | {return static_cast<const _Compare&>(*this) (__x, __y.__get_value().first);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 527 | |
| 528 | template <typename _K2> |
| 529 | _LIBCPP_INLINE_VISIBILITY |
| 530 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 531 | operator () (const _CP& __x, const _K2& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 532 | {return static_cast<const _Compare&>(*this) (__x.__get_value().first, __y);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 533 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 534 | }; |
| 535 | |
Howard Hinnant | 90b9159 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 536 | template <class _Key, class _CP, class _Compare> |
| 537 | class __map_value_compare<_Key, _CP, _Compare, false> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 538 | { |
| 539 | _Compare comp; |
| 540 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 541 | public: |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 542 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 543 | __map_value_compare() |
| 544 | _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) |
| 545 | : comp() {} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 546 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 547 | __map_value_compare(_Compare c) |
| 548 | _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) |
| 549 | : comp(c) {} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 550 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 551 | const _Compare& key_comp() const _NOEXCEPT {return comp;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 552 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 553 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 554 | bool operator()(const _CP& __x, const _CP& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 555 | {return comp(__x.__get_value().first, __y.__get_value().first);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 556 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 557 | bool operator()(const _CP& __x, const _Key& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 558 | {return comp(__x.__get_value().first, __y);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 559 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 560 | bool operator()(const _Key& __x, const _CP& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 561 | {return comp(__x, __y.__get_value().first);} |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 562 | void swap(__map_value_compare&__y) |
| 563 | _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) |
| 564 | { |
| 565 | using _VSTD::swap; |
| 566 | swap(comp, __y.comp); |
| 567 | } |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 568 | |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 569 | #if _LIBCPP_STD_VER > 11 |
| 570 | template <typename _K2> |
| 571 | _LIBCPP_INLINE_VISIBILITY |
| 572 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 573 | operator () ( const _K2& __x, const _CP& __y ) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 574 | {return comp (__x, __y.__get_value().first);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 575 | |
| 576 | template <typename _K2> |
| 577 | _LIBCPP_INLINE_VISIBILITY |
| 578 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type |
| 579 | operator () (const _CP& __x, const _K2& __y) const |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 580 | {return comp (__x.__get_value().first, __y);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 581 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 582 | }; |
| 583 | |
Marshall Clow | 8982dcd | 2015-07-13 20:04:56 +0000 | [diff] [blame] | 584 | template <class _Key, class _CP, class _Compare, bool __b> |
| 585 | inline _LIBCPP_INLINE_VISIBILITY |
| 586 | void |
| 587 | swap(__map_value_compare<_Key, _CP, _Compare, __b>& __x, |
| 588 | __map_value_compare<_Key, _CP, _Compare, __b>& __y) |
| 589 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
| 590 | { |
| 591 | __x.swap(__y); |
| 592 | } |
| 593 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 594 | template <class _Allocator> |
| 595 | class __map_node_destructor |
| 596 | { |
| 597 | typedef _Allocator allocator_type; |
| 598 | typedef allocator_traits<allocator_type> __alloc_traits; |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 599 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 600 | public: |
| 601 | typedef typename __alloc_traits::pointer pointer; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 602 | |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 603 | private: |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 604 | allocator_type& __na_; |
| 605 | |
| 606 | __map_node_destructor& operator=(const __map_node_destructor&); |
| 607 | |
| 608 | public: |
| 609 | bool __first_constructed; |
| 610 | bool __second_constructed; |
| 611 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 612 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 613 | explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 614 | : __na_(__na), |
| 615 | __first_constructed(false), |
| 616 | __second_constructed(false) |
| 617 | {} |
| 618 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 619 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 620 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 621 | __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 622 | : __na_(__x.__na_), |
| 623 | __first_constructed(__x.__value_constructed), |
| 624 | __second_constructed(__x.__value_constructed) |
| 625 | { |
| 626 | __x.__value_constructed = false; |
| 627 | } |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 628 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 629 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 630 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 631 | void operator()(pointer __p) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 632 | { |
| 633 | if (__second_constructed) |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 634 | __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 635 | if (__first_constructed) |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 636 | __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 637 | if (__p) |
| 638 | __alloc_traits::deallocate(__na_, __p, 1); |
| 639 | } |
| 640 | }; |
| 641 | |
Howard Hinnant | 944510a | 2011-06-14 19:58:17 +0000 | [diff] [blame] | 642 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 643 | class map; |
| 644 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 645 | class multimap; |
| 646 | template <class _TreeIterator> class __map_const_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 647 | |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 648 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 649 | |
| 650 | template <class _Key, class _Tp> |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 651 | struct __value_type |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 652 | { |
| 653 | typedef _Key key_type; |
| 654 | typedef _Tp mapped_type; |
| 655 | typedef pair<const key_type, mapped_type> value_type; |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 656 | typedef pair<key_type&, mapped_type&> __nc_ref_pair_type; |
| 657 | typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type; |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 658 | |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 659 | private: |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 660 | value_type __cc; |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 661 | |
| 662 | public: |
| 663 | _LIBCPP_INLINE_VISIBILITY |
| 664 | value_type& __get_value() |
| 665 | { |
| 666 | #if _LIBCPP_STD_VER > 14 |
| 667 | return *_VSTD::launder(_VSTD::addressof(__cc)); |
| 668 | #else |
| 669 | return __cc; |
| 670 | #endif |
| 671 | } |
| 672 | |
| 673 | _LIBCPP_INLINE_VISIBILITY |
| 674 | const value_type& __get_value() const |
| 675 | { |
| 676 | #if _LIBCPP_STD_VER > 14 |
| 677 | return *_VSTD::launder(_VSTD::addressof(__cc)); |
| 678 | #else |
| 679 | return __cc; |
| 680 | #endif |
| 681 | } |
| 682 | |
| 683 | _LIBCPP_INLINE_VISIBILITY |
| 684 | __nc_ref_pair_type __ref() |
| 685 | { |
| 686 | value_type& __v = __get_value(); |
| 687 | return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second); |
| 688 | } |
| 689 | |
| 690 | _LIBCPP_INLINE_VISIBILITY |
| 691 | __nc_rref_pair_type __move() |
| 692 | { |
| 693 | value_type& __v = __get_value(); |
| 694 | return __nc_rref_pair_type( |
| 695 | _VSTD::move(const_cast<key_type&>(__v.first)), |
| 696 | _VSTD::move(__v.second)); |
| 697 | } |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 698 | |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 699 | _LIBCPP_INLINE_VISIBILITY |
| 700 | __value_type& operator=(const __value_type& __v) |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 701 | { |
| 702 | __ref() = __v.__get_value(); |
| 703 | return *this; |
| 704 | } |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 705 | |
| 706 | _LIBCPP_INLINE_VISIBILITY |
| 707 | __value_type& operator=(__value_type&& __v) |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 708 | { |
| 709 | __ref() = __v.__move(); |
| 710 | return *this; |
| 711 | } |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 712 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 713 | template <class _ValueTp, |
| 714 | class = typename enable_if< |
| 715 | __is_same_uncvref<_ValueTp, value_type>::value |
| 716 | >::type |
| 717 | > |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 718 | _LIBCPP_INLINE_VISIBILITY |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 719 | __value_type& operator=(_ValueTp&& __v) |
| 720 | { |
| 721 | __ref() = _VSTD::forward<_ValueTp>(__v); |
| 722 | return *this; |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | private: |
| 726 | __value_type() _LIBCPP_EQUAL_DELETE; |
| 727 | ~__value_type() _LIBCPP_EQUAL_DELETE; |
| 728 | __value_type(const __value_type& __v) _LIBCPP_EQUAL_DELETE; |
| 729 | __value_type(__value_type&& __v) _LIBCPP_EQUAL_DELETE; |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 730 | }; |
| 731 | |
| 732 | #else |
| 733 | |
| 734 | template <class _Key, class _Tp> |
| 735 | struct __value_type |
| 736 | { |
| 737 | typedef _Key key_type; |
| 738 | typedef _Tp mapped_type; |
| 739 | typedef pair<const key_type, mapped_type> value_type; |
| 740 | |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 741 | private: |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 742 | value_type __cc; |
| 743 | |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 744 | public: |
| 745 | _LIBCPP_INLINE_VISIBILITY |
| 746 | value_type& __get_value() { return __cc; } |
| 747 | _LIBCPP_INLINE_VISIBILITY |
| 748 | const value_type& __get_value() const { return __cc; } |
| 749 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 750 | private: |
| 751 | __value_type(); |
| 752 | __value_type(__value_type const&); |
| 753 | __value_type& operator=(__value_type const&); |
| 754 | ~__value_type(); |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 755 | }; |
| 756 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 757 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 758 | |
Eric Fiselier | 44f9fd0 | 2015-03-03 20:10:01 +0000 | [diff] [blame] | 759 | template <class _Tp> |
| 760 | struct __extract_key_value_types; |
| 761 | |
| 762 | template <class _Key, class _Tp> |
| 763 | struct __extract_key_value_types<__value_type<_Key, _Tp> > |
| 764 | { |
| 765 | typedef _Key const __key_type; |
| 766 | typedef _Tp __mapped_type; |
| 767 | }; |
| 768 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 769 | template <class _TreeIterator> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 770 | class _LIBCPP_TEMPLATE_VIS __map_iterator |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 771 | { |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 772 | typedef typename _TreeIterator::_NodeTypes _NodeTypes; |
| 773 | typedef typename _TreeIterator::__pointer_traits __pointer_traits; |
| 774 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 775 | _TreeIterator __i_; |
| 776 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 777 | public: |
| 778 | typedef bidirectional_iterator_tag iterator_category; |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 779 | typedef typename _NodeTypes::__map_value_type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 780 | typedef typename _TreeIterator::difference_type difference_type; |
| 781 | typedef value_type& reference; |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 782 | typedef typename _NodeTypes::__map_value_type_pointer pointer; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 783 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 784 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 785 | __map_iterator() _NOEXCEPT {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 786 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 787 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 788 | __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 789 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 790 | _LIBCPP_INLINE_VISIBILITY |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 791 | reference operator*() const {return __i_->__get_value();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 792 | _LIBCPP_INLINE_VISIBILITY |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 793 | pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 794 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 795 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 796 | __map_iterator& operator++() {++__i_; return *this;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 797 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 798 | __map_iterator operator++(int) |
| 799 | { |
| 800 | __map_iterator __t(*this); |
| 801 | ++(*this); |
| 802 | return __t; |
| 803 | } |
| 804 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 805 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 806 | __map_iterator& operator--() {--__i_; return *this;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 807 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 808 | __map_iterator operator--(int) |
| 809 | { |
| 810 | __map_iterator __t(*this); |
| 811 | --(*this); |
| 812 | return __t; |
| 813 | } |
| 814 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 815 | friend _LIBCPP_INLINE_VISIBILITY |
| 816 | bool operator==(const __map_iterator& __x, const __map_iterator& __y) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 817 | {return __x.__i_ == __y.__i_;} |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 818 | friend |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 819 | _LIBCPP_INLINE_VISIBILITY |
| 820 | bool operator!=(const __map_iterator& __x, const __map_iterator& __y) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 821 | {return __x.__i_ != __y.__i_;} |
| 822 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 823 | template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map; |
| 824 | template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap; |
| 825 | template <class> friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 826 | }; |
| 827 | |
| 828 | template <class _TreeIterator> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 829 | class _LIBCPP_TEMPLATE_VIS __map_const_iterator |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 830 | { |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 831 | typedef typename _TreeIterator::_NodeTypes _NodeTypes; |
| 832 | typedef typename _TreeIterator::__pointer_traits __pointer_traits; |
| 833 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 834 | _TreeIterator __i_; |
| 835 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 836 | public: |
| 837 | typedef bidirectional_iterator_tag iterator_category; |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 838 | typedef typename _NodeTypes::__map_value_type value_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 839 | typedef typename _TreeIterator::difference_type difference_type; |
| 840 | typedef const value_type& reference; |
Eric Fiselier | a00b484 | 2016-02-20 05:28:30 +0000 | [diff] [blame] | 841 | typedef typename _NodeTypes::__const_map_value_type_pointer pointer; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 842 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 843 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 844 | __map_const_iterator() _NOEXCEPT {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 845 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 846 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 847 | __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 848 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | 44f9fd0 | 2015-03-03 20:10:01 +0000 | [diff] [blame] | 849 | __map_const_iterator(__map_iterator< |
| 850 | typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT |
| 851 | : __i_(__i.__i_) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 852 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 853 | _LIBCPP_INLINE_VISIBILITY |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 854 | reference operator*() const {return __i_->__get_value();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 855 | _LIBCPP_INLINE_VISIBILITY |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 856 | pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__get_value());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 857 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 858 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 859 | __map_const_iterator& operator++() {++__i_; return *this;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 860 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 861 | __map_const_iterator operator++(int) |
| 862 | { |
| 863 | __map_const_iterator __t(*this); |
| 864 | ++(*this); |
| 865 | return __t; |
| 866 | } |
| 867 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 868 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 869 | __map_const_iterator& operator--() {--__i_; return *this;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 870 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 871 | __map_const_iterator operator--(int) |
| 872 | { |
| 873 | __map_const_iterator __t(*this); |
| 874 | --(*this); |
| 875 | return __t; |
| 876 | } |
| 877 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 878 | friend _LIBCPP_INLINE_VISIBILITY |
| 879 | bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 880 | {return __x.__i_ == __y.__i_;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 881 | friend _LIBCPP_INLINE_VISIBILITY |
| 882 | bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 883 | {return __x.__i_ != __y.__i_;} |
| 884 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 885 | template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map; |
| 886 | template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap; |
| 887 | template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 888 | }; |
| 889 | |
| 890 | template <class _Key, class _Tp, class _Compare = less<_Key>, |
| 891 | class _Allocator = allocator<pair<const _Key, _Tp> > > |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 892 | class _LIBCPP_TEMPLATE_VIS map |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 893 | { |
| 894 | public: |
| 895 | // types: |
| 896 | typedef _Key key_type; |
| 897 | typedef _Tp mapped_type; |
| 898 | typedef pair<const key_type, mapped_type> value_type; |
| 899 | typedef _Compare key_compare; |
| 900 | typedef _Allocator allocator_type; |
| 901 | typedef value_type& reference; |
| 902 | typedef const value_type& const_reference; |
| 903 | |
Louis Dionne | 878a3a8 | 2018-12-06 21:46:17 +0000 | [diff] [blame] | 904 | static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
Marshall Clow | 5128cf3 | 2015-11-26 01:24:04 +0000 | [diff] [blame] | 905 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 906 | "Allocator::value_type must be same type as value_type"); |
| 907 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 908 | class _LIBCPP_TEMPLATE_VIS value_compare |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 909 | : public binary_function<value_type, value_type, bool> |
| 910 | { |
| 911 | friend class map; |
| 912 | protected: |
| 913 | key_compare comp; |
| 914 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 915 | _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 916 | public: |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 917 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 918 | bool operator()(const value_type& __x, const value_type& __y) const |
| 919 | {return comp(__x.first, __y.first);} |
| 920 | }; |
| 921 | |
| 922 | private: |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 923 | |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 924 | typedef _VSTD::__value_type<key_type, mapped_type> __value_type; |
Howard Hinnant | 90b9159 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 925 | typedef __map_value_compare<key_type, __value_type, key_compare> __vc; |
Marshall Clow | 940e01c | 2015-04-07 05:21:38 +0000 | [diff] [blame] | 926 | typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, |
| 927 | __value_type>::type __allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 928 | typedef __tree<__value_type, __vc, __allocator_type> __base; |
| 929 | typedef typename __base::__node_traits __node_traits; |
| 930 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 931 | |
| 932 | __base __tree_; |
| 933 | |
| 934 | public: |
| 935 | typedef typename __alloc_traits::pointer pointer; |
| 936 | typedef typename __alloc_traits::const_pointer const_pointer; |
| 937 | typedef typename __alloc_traits::size_type size_type; |
| 938 | typedef typename __alloc_traits::difference_type difference_type; |
Eric Fiselier | 44f9fd0 | 2015-03-03 20:10:01 +0000 | [diff] [blame] | 939 | typedef __map_iterator<typename __base::iterator> iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 940 | typedef __map_const_iterator<typename __base::const_iterator> const_iterator; |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 941 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 942 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 943 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 944 | #if _LIBCPP_STD_VER > 14 |
| 945 | typedef __map_node_handle<typename __base::__node, allocator_type> node_type; |
| 946 | typedef __insert_return_type<iterator, node_type> insert_return_type; |
| 947 | #endif |
| 948 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 949 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 950 | friend class _LIBCPP_TEMPLATE_VIS map; |
| 951 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 952 | friend class _LIBCPP_TEMPLATE_VIS multimap; |
| 953 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 954 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 955 | map() |
| 956 | _NOEXCEPT_( |
| 957 | is_nothrow_default_constructible<allocator_type>::value && |
| 958 | is_nothrow_default_constructible<key_compare>::value && |
| 959 | is_nothrow_copy_constructible<key_compare>::value) |
| 960 | : __tree_(__vc(key_compare())) {} |
| 961 | |
| 962 | _LIBCPP_INLINE_VISIBILITY |
| 963 | explicit map(const key_compare& __comp) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 964 | _NOEXCEPT_( |
| 965 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 966 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 967 | : __tree_(__vc(__comp)) {} |
| 968 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 969 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 970 | explicit map(const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 971 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 972 | |
| 973 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 974 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 975 | map(_InputIterator __f, _InputIterator __l, |
| 976 | const key_compare& __comp = key_compare()) |
| 977 | : __tree_(__vc(__comp)) |
| 978 | { |
| 979 | insert(__f, __l); |
| 980 | } |
| 981 | |
| 982 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 983 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 984 | map(_InputIterator __f, _InputIterator __l, |
| 985 | const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 986 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 987 | { |
| 988 | insert(__f, __l); |
| 989 | } |
| 990 | |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 991 | #if _LIBCPP_STD_VER > 11 |
| 992 | template <class _InputIterator> |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 993 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 994 | map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 995 | : map(__f, __l, key_compare(), __a) {} |
| 996 | #endif |
| 997 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 998 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 999 | map(const map& __m) |
| 1000 | : __tree_(__m.__tree_) |
| 1001 | { |
| 1002 | insert(__m.begin(), __m.end()); |
| 1003 | } |
| 1004 | |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1005 | _LIBCPP_INLINE_VISIBILITY |
| 1006 | map& operator=(const map& __m) |
| 1007 | { |
Marshall Clow | 476d3f4 | 2016-07-18 13:19:00 +0000 | [diff] [blame] | 1008 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1009 | __tree_ = __m.__tree_; |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1010 | #else |
Marshall Clow | db3cfcb | 2014-02-08 04:03:14 +0000 | [diff] [blame] | 1011 | if (this != &__m) { |
| 1012 | __tree_.clear(); |
| 1013 | __tree_.value_comp() = __m.__tree_.value_comp(); |
| 1014 | __tree_.__copy_assign_alloc(__m.__tree_); |
| 1015 | insert(__m.begin(), __m.end()); |
| 1016 | } |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1017 | #endif |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1018 | return *this; |
| 1019 | } |
| 1020 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1021 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1022 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1023 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1024 | map(map&& __m) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1025 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1026 | : __tree_(_VSTD::move(__m.__tree_)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1027 | { |
| 1028 | } |
| 1029 | |
| 1030 | map(map&& __m, const allocator_type& __a); |
| 1031 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1032 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 3371179 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1033 | map& operator=(map&& __m) |
| 1034 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
| 1035 | { |
| 1036 | __tree_ = _VSTD::move(__m.__tree_); |
| 1037 | return *this; |
| 1038 | } |
| 1039 | |
Howard Hinnant | 3371179 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1040 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1041 | map(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) |
| 1042 | : __tree_(__vc(__comp)) |
| 1043 | { |
| 1044 | insert(__il.begin(), __il.end()); |
| 1045 | } |
| 1046 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1047 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1048 | map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1049 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1050 | { |
| 1051 | insert(__il.begin(), __il.end()); |
| 1052 | } |
| 1053 | |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1054 | #if _LIBCPP_STD_VER > 11 |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1055 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1056 | map(initializer_list<value_type> __il, const allocator_type& __a) |
| 1057 | : map(__il, key_compare(), __a) {} |
| 1058 | #endif |
| 1059 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1060 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1061 | map& operator=(initializer_list<value_type> __il) |
| 1062 | { |
| 1063 | __tree_.__assign_unique(__il.begin(), __il.end()); |
| 1064 | return *this; |
| 1065 | } |
| 1066 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1067 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1068 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1069 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1070 | explicit map(const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1071 | : __tree_(typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1072 | { |
| 1073 | } |
| 1074 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1075 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1076 | map(const map& __m, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1077 | : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1078 | { |
| 1079 | insert(__m.begin(), __m.end()); |
| 1080 | } |
| 1081 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1082 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1083 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1084 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1085 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1086 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1087 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1088 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1089 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1090 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1091 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1092 | reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1093 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1094 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 1095 | {return const_reverse_iterator(end());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1096 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1097 | reverse_iterator rend() _NOEXCEPT |
| 1098 | {return reverse_iterator(begin());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1099 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1100 | const_reverse_iterator rend() const _NOEXCEPT |
| 1101 | {return const_reverse_iterator(begin());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1102 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1103 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1104 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1105 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1106 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1107 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1108 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1109 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1110 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1111 | |
Marshall Clow | 425f575 | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 1112 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1113 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1114 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1115 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1116 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1117 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1118 | |
| 1119 | mapped_type& operator[](const key_type& __k); |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1120 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1121 | mapped_type& operator[](key_type&& __k); |
| 1122 | #endif |
| 1123 | |
| 1124 | mapped_type& at(const key_type& __k); |
| 1125 | const mapped_type& at(const key_type& __k) const; |
| 1126 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1127 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1128 | allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1129 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1130 | key_compare key_comp() const {return __tree_.value_comp().key_comp();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1131 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1132 | value_compare value_comp() const {return value_compare(__tree_.value_comp().key_comp());} |
| 1133 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1134 | #ifndef _LIBCPP_CXX03_LANG |
| 1135 | template <class ..._Args> |
| 1136 | _LIBCPP_INLINE_VISIBILITY |
| 1137 | pair<iterator, bool> emplace(_Args&& ...__args) { |
| 1138 | return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...); |
| 1139 | } |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1140 | |
Howard Hinnant | 29eb9b8 | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1141 | template <class ..._Args> |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1142 | _LIBCPP_INLINE_VISIBILITY |
| 1143 | iterator emplace_hint(const_iterator __p, _Args&& ...__args) { |
| 1144 | return __tree_.__emplace_hint_unique(__p.__i_, _VSTD::forward<_Args>(__args)...); |
| 1145 | } |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1146 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1147 | template <class _Pp, |
| 1148 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1149 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1150 | pair<iterator, bool> insert(_Pp&& __p) |
| 1151 | {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1152 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1153 | template <class _Pp, |
| 1154 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1155 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1156 | iterator insert(const_iterator __pos, _Pp&& __p) |
| 1157 | {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1158 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1159 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1160 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1161 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1162 | pair<iterator, bool> |
| 1163 | insert(const value_type& __v) {return __tree_.__insert_unique(__v);} |
| 1164 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1165 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1166 | iterator |
| 1167 | insert(const_iterator __p, const value_type& __v) |
| 1168 | {return __tree_.__insert_unique(__p.__i_, __v);} |
| 1169 | |
Eric Fiselier | d614313 | 2016-04-18 01:40:45 +0000 | [diff] [blame] | 1170 | #ifndef _LIBCPP_CXX03_LANG |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 1171 | _LIBCPP_INLINE_VISIBILITY |
| 1172 | pair<iterator, bool> |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1173 | insert(value_type&& __v) {return __tree_.__insert_unique(_VSTD::move(__v));} |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 1174 | |
| 1175 | _LIBCPP_INLINE_VISIBILITY |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1176 | iterator insert(const_iterator __p, value_type&& __v) |
| 1177 | {return __tree_.__insert_unique(__p.__i_, _VSTD::move(__v));} |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1178 | |
| 1179 | _LIBCPP_INLINE_VISIBILITY |
| 1180 | void insert(initializer_list<value_type> __il) |
| 1181 | {insert(__il.begin(), __il.end());} |
Marshall Clow | d430d02 | 2016-01-05 19:32:41 +0000 | [diff] [blame] | 1182 | #endif |
| 1183 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1184 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1185 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1186 | void insert(_InputIterator __f, _InputIterator __l) |
| 1187 | { |
| 1188 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 1189 | insert(__e.__i_, *__f); |
| 1190 | } |
| 1191 | |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1192 | #if _LIBCPP_STD_VER > 14 |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1193 | |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1194 | template <class... _Args> |
| 1195 | _LIBCPP_INLINE_VISIBILITY |
| 1196 | pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) |
| 1197 | { |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1198 | return __tree_.__emplace_unique_key_args(__k, |
| 1199 | _VSTD::piecewise_construct, |
| 1200 | _VSTD::forward_as_tuple(__k), |
| 1201 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1202 | } |
| 1203 | |
| 1204 | template <class... _Args> |
| 1205 | _LIBCPP_INLINE_VISIBILITY |
| 1206 | pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) |
| 1207 | { |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1208 | return __tree_.__emplace_unique_key_args(__k, |
| 1209 | _VSTD::piecewise_construct, |
| 1210 | _VSTD::forward_as_tuple(_VSTD::move(__k)), |
| 1211 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1212 | } |
| 1213 | |
| 1214 | template <class... _Args> |
| 1215 | _LIBCPP_INLINE_VISIBILITY |
| 1216 | iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) |
| 1217 | { |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1218 | return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, |
| 1219 | _VSTD::piecewise_construct, |
| 1220 | _VSTD::forward_as_tuple(__k), |
| 1221 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1222 | } |
| 1223 | |
| 1224 | template <class... _Args> |
| 1225 | _LIBCPP_INLINE_VISIBILITY |
| 1226 | iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) |
| 1227 | { |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1228 | return __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, |
| 1229 | _VSTD::piecewise_construct, |
| 1230 | _VSTD::forward_as_tuple(_VSTD::move(__k)), |
| 1231 | _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | template <class _Vp> |
| 1235 | _LIBCPP_INLINE_VISIBILITY |
| 1236 | pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) |
| 1237 | { |
| 1238 | iterator __p = lower_bound(__k); |
| 1239 | if ( __p != end() && !key_comp()(__k, __p->first)) |
| 1240 | { |
| 1241 | __p->second = _VSTD::forward<_Vp>(__v); |
| 1242 | return _VSTD::make_pair(__p, false); |
| 1243 | } |
| 1244 | return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true); |
| 1245 | } |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1246 | |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1247 | template <class _Vp> |
| 1248 | _LIBCPP_INLINE_VISIBILITY |
| 1249 | pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) |
| 1250 | { |
| 1251 | iterator __p = lower_bound(__k); |
| 1252 | if ( __p != end() && !key_comp()(__k, __p->first)) |
| 1253 | { |
| 1254 | __p->second = _VSTD::forward<_Vp>(__v); |
| 1255 | return _VSTD::make_pair(__p, false); |
| 1256 | } |
| 1257 | return _VSTD::make_pair(emplace_hint(__p, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)), true); |
| 1258 | } |
| 1259 | |
| 1260 | template <class _Vp> |
| 1261 | _LIBCPP_INLINE_VISIBILITY |
| 1262 | iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) |
| 1263 | { |
| 1264 | iterator __p = lower_bound(__k); |
| 1265 | if ( __p != end() && !key_comp()(__k, __p->first)) |
| 1266 | { |
| 1267 | __p->second = _VSTD::forward<_Vp>(__v); |
| 1268 | return __p; |
| 1269 | } |
| 1270 | return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v)); |
| 1271 | } |
| 1272 | |
| 1273 | template <class _Vp> |
| 1274 | _LIBCPP_INLINE_VISIBILITY |
| 1275 | iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) |
| 1276 | { |
| 1277 | iterator __p = lower_bound(__k); |
| 1278 | if ( __p != end() && !key_comp()(__k, __p->first)) |
| 1279 | { |
| 1280 | __p->second = _VSTD::forward<_Vp>(__v); |
| 1281 | return __p; |
| 1282 | } |
| 1283 | return emplace_hint(__h, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)); |
| 1284 | } |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1285 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1286 | #endif // _LIBCPP_STD_VER > 14 |
Marshall Clow | 3223db8 | 2015-07-07 03:37:33 +0000 | [diff] [blame] | 1287 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1288 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1289 | iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1290 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 1291 | iterator erase(iterator __p) {return __tree_.erase(__p.__i_);} |
| 1292 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1293 | size_type erase(const key_type& __k) |
| 1294 | {return __tree_.__erase_unique(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1295 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1296 | iterator erase(const_iterator __f, const_iterator __l) |
| 1297 | {return __tree_.erase(__f.__i_, __l.__i_);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1298 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1299 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1300 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1301 | #if _LIBCPP_STD_VER > 14 |
| 1302 | _LIBCPP_INLINE_VISIBILITY |
| 1303 | insert_return_type insert(node_type&& __nh) |
| 1304 | { |
| 1305 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1306 | "node_type with incompatible allocator passed to map::insert()"); |
| 1307 | return __tree_.template __node_handle_insert_unique< |
| 1308 | node_type, insert_return_type>(_VSTD::move(__nh)); |
| 1309 | } |
| 1310 | _LIBCPP_INLINE_VISIBILITY |
| 1311 | iterator insert(const_iterator __hint, node_type&& __nh) |
| 1312 | { |
| 1313 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1314 | "node_type with incompatible allocator passed to map::insert()"); |
| 1315 | return __tree_.template __node_handle_insert_unique<node_type>( |
| 1316 | __hint.__i_, _VSTD::move(__nh)); |
| 1317 | } |
| 1318 | _LIBCPP_INLINE_VISIBILITY |
| 1319 | node_type extract(key_type const& __key) |
| 1320 | { |
| 1321 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 1322 | } |
| 1323 | _LIBCPP_INLINE_VISIBILITY |
| 1324 | node_type extract(const_iterator __it) |
| 1325 | { |
| 1326 | return __tree_.template __node_handle_extract<node_type>(__it.__i_); |
| 1327 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1328 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1329 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1330 | void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1331 | { |
| 1332 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1333 | "merging container with incompatible allocator"); |
| 1334 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 1335 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1336 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1337 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1338 | void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1339 | { |
| 1340 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1341 | "merging container with incompatible allocator"); |
| 1342 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 1343 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1344 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1345 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1346 | void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1347 | { |
| 1348 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1349 | "merging container with incompatible allocator"); |
| 1350 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 1351 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1352 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1353 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1354 | void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1355 | { |
| 1356 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1357 | "merging container with incompatible allocator"); |
| 1358 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 1359 | } |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1360 | #endif |
| 1361 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1362 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1363 | void swap(map& __m) |
| 1364 | _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 1365 | {__tree_.swap(__m.__tree_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1366 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1367 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1368 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1369 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1370 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1371 | #if _LIBCPP_STD_VER > 11 |
| 1372 | template <typename _K2> |
| 1373 | _LIBCPP_INLINE_VISIBILITY |
| 1374 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1375 | find(const _K2& __k) {return __tree_.find(__k);} |
| 1376 | template <typename _K2> |
| 1377 | _LIBCPP_INLINE_VISIBILITY |
| 1378 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1379 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 1380 | #endif |
| 1381 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1382 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1383 | size_type count(const key_type& __k) const |
| 1384 | {return __tree_.__count_unique(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 1385 | #if _LIBCPP_STD_VER > 11 |
| 1386 | template <typename _K2> |
| 1387 | _LIBCPP_INLINE_VISIBILITY |
| 1388 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 1389 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 1390 | #endif |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1391 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1392 | iterator lower_bound(const key_type& __k) |
| 1393 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1394 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1395 | const_iterator lower_bound(const key_type& __k) const |
| 1396 | {return __tree_.lower_bound(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1397 | #if _LIBCPP_STD_VER > 11 |
| 1398 | template <typename _K2> |
| 1399 | _LIBCPP_INLINE_VISIBILITY |
| 1400 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1401 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 1402 | |
| 1403 | template <typename _K2> |
| 1404 | _LIBCPP_INLINE_VISIBILITY |
| 1405 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1406 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 1407 | #endif |
| 1408 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1409 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1410 | iterator upper_bound(const key_type& __k) |
| 1411 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1412 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1413 | const_iterator upper_bound(const key_type& __k) const |
| 1414 | {return __tree_.upper_bound(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1415 | #if _LIBCPP_STD_VER > 11 |
| 1416 | template <typename _K2> |
| 1417 | _LIBCPP_INLINE_VISIBILITY |
| 1418 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1419 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 1420 | template <typename _K2> |
| 1421 | _LIBCPP_INLINE_VISIBILITY |
| 1422 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 1423 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 1424 | #endif |
| 1425 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1426 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1427 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 1428 | {return __tree_.__equal_range_unique(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1429 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1430 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 1431 | {return __tree_.__equal_range_unique(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1432 | #if _LIBCPP_STD_VER > 11 |
| 1433 | template <typename _K2> |
| 1434 | _LIBCPP_INLINE_VISIBILITY |
| 1435 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
Eric Fiselier | a85c9e9 | 2018-02-10 02:53:47 +0000 | [diff] [blame] | 1436 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1437 | template <typename _K2> |
| 1438 | _LIBCPP_INLINE_VISIBILITY |
| 1439 | 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] | 1440 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1441 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1442 | |
| 1443 | private: |
| 1444 | typedef typename __base::__node __node; |
| 1445 | typedef typename __base::__node_allocator __node_allocator; |
| 1446 | typedef typename __base::__node_pointer __node_pointer; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1447 | typedef typename __base::__node_base_pointer __node_base_pointer; |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1448 | typedef typename __base::__parent_pointer __parent_pointer; |
Eric Fiselier | a92b073 | 2016-02-20 07:12:17 +0000 | [diff] [blame] | 1449 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1450 | typedef __map_node_destructor<__node_allocator> _Dp; |
| 1451 | typedef unique_ptr<__node, _Dp> __node_holder; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1452 | |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1453 | #ifdef _LIBCPP_CXX03_LANG |
Howard Hinnant | ac7e748 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1454 | __node_holder __construct_node_with_key(const key_type& __k); |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1455 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1456 | }; |
| 1457 | |
Eric Fiselier | a92b073 | 2016-02-20 07:12:17 +0000 | [diff] [blame] | 1458 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1459 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1460 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1461 | map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1462 | : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1463 | { |
| 1464 | if (__a != __m.get_allocator()) |
| 1465 | { |
| 1466 | const_iterator __e = cend(); |
| 1467 | while (!__m.empty()) |
| 1468 | __tree_.__insert_unique(__e.__i_, |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1469 | __m.__tree_.remove(__m.begin().__i_)->__value_.__move()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1470 | } |
| 1471 | } |
| 1472 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1473 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1474 | _Tp& |
| 1475 | map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) |
| 1476 | { |
| 1477 | return __tree_.__emplace_unique_key_args(__k, |
| 1478 | _VSTD::piecewise_construct, |
| 1479 | _VSTD::forward_as_tuple(__k), |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1480 | _VSTD::forward_as_tuple()).first->__get_value().second; |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1481 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1482 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1483 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1484 | _Tp& |
| 1485 | map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) |
| 1486 | { |
| 1487 | return __tree_.__emplace_unique_key_args(__k, |
| 1488 | _VSTD::piecewise_construct, |
| 1489 | _VSTD::forward_as_tuple(_VSTD::move(__k)), |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1490 | _VSTD::forward_as_tuple()).first->__get_value().second; |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1491 | } |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1492 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1493 | #else // _LIBCPP_CXX03_LANG |
Eric Fiselier | d63f38e | 2016-03-31 03:13:37 +0000 | [diff] [blame] | 1494 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1495 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1496 | typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder |
Howard Hinnant | ac7e748 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1497 | map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1498 | { |
| 1499 | __node_allocator& __na = __tree_.__node_alloc(); |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1500 | __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1501 | __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1502 | __h.get_deleter().__first_constructed = true; |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1503 | __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second)); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1504 | __h.get_deleter().__second_constructed = true; |
Dimitry Andric | 830fb60 | 2015-08-19 06:43:33 +0000 | [diff] [blame] | 1505 | return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1506 | } |
| 1507 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1508 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1509 | _Tp& |
| 1510 | map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) |
| 1511 | { |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1512 | __parent_pointer __parent; |
| 1513 | __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1514 | __node_pointer __r = static_cast<__node_pointer>(__child); |
| 1515 | if (__child == nullptr) |
| 1516 | { |
Howard Hinnant | ac7e748 | 2013-07-04 20:59:16 +0000 | [diff] [blame] | 1517 | __node_holder __h = __construct_node_with_key(__k); |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1518 | __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1519 | __r = __h.release(); |
| 1520 | } |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1521 | return __r->__value_.__get_value().second; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1522 | } |
| 1523 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1524 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1525 | |
| 1526 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1527 | _Tp& |
| 1528 | map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) |
| 1529 | { |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1530 | __parent_pointer __parent; |
| 1531 | __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); |
Howard Hinnant | 72f7358 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 1532 | #ifndef _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1533 | if (__child == nullptr) |
| 1534 | throw out_of_range("map::at: key not found"); |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1535 | #endif // _LIBCPP_NO_EXCEPTIONS |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1536 | return static_cast<__node_pointer>(__child)->__value_.__get_value().second; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1537 | } |
| 1538 | |
| 1539 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1540 | const _Tp& |
| 1541 | map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const |
| 1542 | { |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1543 | __parent_pointer __parent; |
| 1544 | __node_base_pointer __child = __tree_.__find_equal(__parent, __k); |
Howard Hinnant | 72f7358 | 2010-08-11 17:04:31 +0000 | [diff] [blame] | 1545 | #ifndef _LIBCPP_NO_EXCEPTIONS |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1546 | if (__child == nullptr) |
| 1547 | throw out_of_range("map::at: key not found"); |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 1548 | #endif // _LIBCPP_NO_EXCEPTIONS |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 1549 | return static_cast<__node_pointer>(__child)->__value_.__get_value().second; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1550 | } |
| 1551 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1552 | |
| 1553 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1554 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1555 | bool |
| 1556 | operator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1557 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1558 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1559 | 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] | 1560 | } |
| 1561 | |
| 1562 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1563 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1564 | bool |
| 1565 | operator< (const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1566 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1567 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1568 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1569 | } |
| 1570 | |
| 1571 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1572 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1573 | bool |
| 1574 | operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1575 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1576 | { |
| 1577 | return !(__x == __y); |
| 1578 | } |
| 1579 | |
| 1580 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1581 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1582 | bool |
| 1583 | operator> (const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1584 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1585 | { |
| 1586 | return __y < __x; |
| 1587 | } |
| 1588 | |
| 1589 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1590 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1591 | bool |
| 1592 | operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1593 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1594 | { |
| 1595 | return !(__x < __y); |
| 1596 | } |
| 1597 | |
| 1598 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1599 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1600 | bool |
| 1601 | operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1602 | const map<_Key, _Tp, _Compare, _Allocator>& __y) |
| 1603 | { |
| 1604 | return !(__y < __x); |
| 1605 | } |
| 1606 | |
| 1607 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1608 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1609 | void |
| 1610 | swap(map<_Key, _Tp, _Compare, _Allocator>& __x, |
| 1611 | map<_Key, _Tp, _Compare, _Allocator>& __y) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1612 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1613 | { |
| 1614 | __x.swap(__y); |
| 1615 | } |
| 1616 | |
| 1617 | template <class _Key, class _Tp, class _Compare = less<_Key>, |
| 1618 | class _Allocator = allocator<pair<const _Key, _Tp> > > |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1619 | class _LIBCPP_TEMPLATE_VIS multimap |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1620 | { |
| 1621 | public: |
| 1622 | // types: |
| 1623 | typedef _Key key_type; |
| 1624 | typedef _Tp mapped_type; |
| 1625 | typedef pair<const key_type, mapped_type> value_type; |
| 1626 | typedef _Compare key_compare; |
| 1627 | typedef _Allocator allocator_type; |
| 1628 | typedef value_type& reference; |
| 1629 | typedef const value_type& const_reference; |
| 1630 | |
Louis Dionne | 878a3a8 | 2018-12-06 21:46:17 +0000 | [diff] [blame] | 1631 | static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); |
Marshall Clow | 5128cf3 | 2015-11-26 01:24:04 +0000 | [diff] [blame] | 1632 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 1633 | "Allocator::value_type must be same type as value_type"); |
| 1634 | |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 1635 | class _LIBCPP_TEMPLATE_VIS value_compare |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1636 | : public binary_function<value_type, value_type, bool> |
| 1637 | { |
| 1638 | friend class multimap; |
| 1639 | protected: |
| 1640 | key_compare comp; |
| 1641 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1642 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1643 | value_compare(key_compare c) : comp(c) {} |
| 1644 | public: |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1645 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1646 | bool operator()(const value_type& __x, const value_type& __y) const |
| 1647 | {return comp(__x.first, __y.first);} |
| 1648 | }; |
| 1649 | |
| 1650 | private: |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1651 | |
Howard Hinnant | 89f8b79 | 2013-09-30 19:08:22 +0000 | [diff] [blame] | 1652 | typedef _VSTD::__value_type<key_type, mapped_type> __value_type; |
Howard Hinnant | 90b9159 | 2013-07-05 18:06:00 +0000 | [diff] [blame] | 1653 | typedef __map_value_compare<key_type, __value_type, key_compare> __vc; |
Marshall Clow | 940e01c | 2015-04-07 05:21:38 +0000 | [diff] [blame] | 1654 | typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, |
| 1655 | __value_type>::type __allocator_type; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1656 | typedef __tree<__value_type, __vc, __allocator_type> __base; |
| 1657 | typedef typename __base::__node_traits __node_traits; |
| 1658 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1659 | |
| 1660 | __base __tree_; |
| 1661 | |
| 1662 | public: |
| 1663 | typedef typename __alloc_traits::pointer pointer; |
| 1664 | typedef typename __alloc_traits::const_pointer const_pointer; |
| 1665 | typedef typename __alloc_traits::size_type size_type; |
| 1666 | typedef typename __alloc_traits::difference_type difference_type; |
| 1667 | typedef __map_iterator<typename __base::iterator> iterator; |
| 1668 | typedef __map_const_iterator<typename __base::const_iterator> const_iterator; |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1669 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; |
| 1670 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1671 | |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1672 | #if _LIBCPP_STD_VER > 14 |
| 1673 | typedef __map_node_handle<typename __base::__node, allocator_type> node_type; |
| 1674 | #endif |
| 1675 | |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1676 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1677 | friend class _LIBCPP_TEMPLATE_VIS map; |
| 1678 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1679 | friend class _LIBCPP_TEMPLATE_VIS multimap; |
| 1680 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1681 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 7086a5a | 2014-03-10 04:50:10 +0000 | [diff] [blame] | 1682 | multimap() |
| 1683 | _NOEXCEPT_( |
| 1684 | is_nothrow_default_constructible<allocator_type>::value && |
| 1685 | is_nothrow_default_constructible<key_compare>::value && |
| 1686 | is_nothrow_copy_constructible<key_compare>::value) |
| 1687 | : __tree_(__vc(key_compare())) {} |
| 1688 | |
| 1689 | _LIBCPP_INLINE_VISIBILITY |
| 1690 | explicit multimap(const key_compare& __comp) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1691 | _NOEXCEPT_( |
| 1692 | is_nothrow_default_constructible<allocator_type>::value && |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1693 | is_nothrow_copy_constructible<key_compare>::value) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1694 | : __tree_(__vc(__comp)) {} |
| 1695 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1696 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1697 | explicit multimap(const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1698 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1699 | |
| 1700 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1701 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1702 | multimap(_InputIterator __f, _InputIterator __l, |
| 1703 | const key_compare& __comp = key_compare()) |
| 1704 | : __tree_(__vc(__comp)) |
| 1705 | { |
| 1706 | insert(__f, __l); |
| 1707 | } |
| 1708 | |
| 1709 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1710 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1711 | multimap(_InputIterator __f, _InputIterator __l, |
| 1712 | const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1713 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1714 | { |
| 1715 | insert(__f, __l); |
| 1716 | } |
| 1717 | |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1718 | #if _LIBCPP_STD_VER > 11 |
| 1719 | template <class _InputIterator> |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1720 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1721 | multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 1722 | : multimap(__f, __l, key_compare(), __a) {} |
| 1723 | #endif |
| 1724 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1725 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1726 | multimap(const multimap& __m) |
| 1727 | : __tree_(__m.__tree_.value_comp(), |
| 1728 | __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc())) |
| 1729 | { |
| 1730 | insert(__m.begin(), __m.end()); |
| 1731 | } |
| 1732 | |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1733 | _LIBCPP_INLINE_VISIBILITY |
| 1734 | multimap& operator=(const multimap& __m) |
| 1735 | { |
Marshall Clow | 476d3f4 | 2016-07-18 13:19:00 +0000 | [diff] [blame] | 1736 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1737 | __tree_ = __m.__tree_; |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1738 | #else |
Marshall Clow | db3cfcb | 2014-02-08 04:03:14 +0000 | [diff] [blame] | 1739 | if (this != &__m) { |
| 1740 | __tree_.clear(); |
| 1741 | __tree_.value_comp() = __m.__tree_.value_comp(); |
| 1742 | __tree_.__copy_assign_alloc(__m.__tree_); |
| 1743 | insert(__m.begin(), __m.end()); |
| 1744 | } |
Howard Hinnant | 2d0046b | 2013-06-19 21:29:40 +0000 | [diff] [blame] | 1745 | #endif |
Howard Hinnant | d3a657f | 2011-07-01 19:24:36 +0000 | [diff] [blame] | 1746 | return *this; |
| 1747 | } |
| 1748 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1749 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1750 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1751 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1752 | multimap(multimap&& __m) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1753 | _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 1754 | : __tree_(_VSTD::move(__m.__tree_)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1755 | { |
| 1756 | } |
| 1757 | |
| 1758 | multimap(multimap&& __m, const allocator_type& __a); |
| 1759 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1760 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 3371179 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1761 | multimap& operator=(multimap&& __m) |
| 1762 | _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) |
| 1763 | { |
| 1764 | __tree_ = _VSTD::move(__m.__tree_); |
| 1765 | return *this; |
| 1766 | } |
| 1767 | |
Howard Hinnant | 3371179 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1768 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1769 | multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) |
| 1770 | : __tree_(__vc(__comp)) |
| 1771 | { |
| 1772 | insert(__il.begin(), __il.end()); |
| 1773 | } |
| 1774 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1775 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1776 | multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1777 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1778 | { |
| 1779 | insert(__il.begin(), __il.end()); |
| 1780 | } |
| 1781 | |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1782 | #if _LIBCPP_STD_VER > 11 |
Eric Fiselier | cf8c021 | 2017-01-05 06:06:18 +0000 | [diff] [blame] | 1783 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 300abfb | 2013-09-11 01:15:47 +0000 | [diff] [blame] | 1784 | multimap(initializer_list<value_type> __il, const allocator_type& __a) |
| 1785 | : multimap(__il, key_compare(), __a) {} |
| 1786 | #endif |
| 1787 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1788 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1789 | multimap& operator=(initializer_list<value_type> __il) |
| 1790 | { |
| 1791 | __tree_.__assign_multi(__il.begin(), __il.end()); |
| 1792 | return *this; |
| 1793 | } |
Howard Hinnant | 3371179 | 2011-08-12 21:56:02 +0000 | [diff] [blame] | 1794 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1795 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1796 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1797 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1798 | explicit multimap(const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1799 | : __tree_(typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1800 | { |
| 1801 | } |
| 1802 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1803 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1804 | multimap(const multimap& __m, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1805 | : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1806 | { |
| 1807 | insert(__m.begin(), __m.end()); |
| 1808 | } |
| 1809 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1810 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1811 | iterator begin() _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1812 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1813 | const_iterator begin() const _NOEXCEPT {return __tree_.begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1814 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1815 | iterator end() _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1816 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1817 | const_iterator end() const _NOEXCEPT {return __tree_.end();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1818 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1819 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1820 | reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1821 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1822 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 1823 | {return const_reverse_iterator(end());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1824 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1825 | reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1826 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1827 | const_reverse_iterator rend() const _NOEXCEPT |
| 1828 | {return const_reverse_iterator(begin());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1829 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1830 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1831 | const_iterator cbegin() const _NOEXCEPT {return begin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1832 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1833 | const_iterator cend() const _NOEXCEPT {return end();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1834 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1835 | const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1836 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1837 | const_reverse_iterator crend() const _NOEXCEPT {return rend();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1838 | |
Marshall Clow | 425f575 | 2017-11-15 05:51:26 +0000 | [diff] [blame] | 1839 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1840 | bool empty() const _NOEXCEPT {return __tree_.size() == 0;} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1841 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1842 | size_type size() const _NOEXCEPT {return __tree_.size();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1843 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1844 | size_type max_size() const _NOEXCEPT {return __tree_.max_size();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1845 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1846 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 1847 | allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1848 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1849 | key_compare key_comp() const {return __tree_.value_comp().key_comp();} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1850 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1851 | value_compare value_comp() const |
| 1852 | {return value_compare(__tree_.value_comp().key_comp());} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1853 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1854 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1855 | |
Howard Hinnant | 29eb9b8 | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1856 | template <class ..._Args> |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1857 | _LIBCPP_INLINE_VISIBILITY |
| 1858 | iterator emplace(_Args&& ...__args) { |
| 1859 | return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...); |
| 1860 | } |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1861 | |
Howard Hinnant | 29eb9b8 | 2012-05-25 22:04:21 +0000 | [diff] [blame] | 1862 | template <class ..._Args> |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1863 | _LIBCPP_INLINE_VISIBILITY |
| 1864 | iterator emplace_hint(const_iterator __p, _Args&& ...__args) { |
| 1865 | return __tree_.__emplace_hint_multi(__p.__i_, _VSTD::forward<_Args>(__args)...); |
| 1866 | } |
Howard Hinnant | 74279a5 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 1867 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1868 | template <class _Pp, |
| 1869 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1870 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1871 | iterator insert(_Pp&& __p) |
| 1872 | {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1873 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1874 | template <class _Pp, |
| 1875 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1876 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 1877 | iterator insert(const_iterator __pos, _Pp&& __p) |
| 1878 | {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1879 | |
Eric Fiselier | d614313 | 2016-04-18 01:40:45 +0000 | [diff] [blame] | 1880 | _LIBCPP_INLINE_VISIBILITY |
| 1881 | iterator insert(value_type&& __v) |
| 1882 | {return __tree_.__insert_multi(_VSTD::move(__v));} |
| 1883 | |
| 1884 | _LIBCPP_INLINE_VISIBILITY |
| 1885 | iterator insert(const_iterator __p, value_type&& __v) |
| 1886 | {return __tree_.__insert_multi(__p.__i_, _VSTD::move(__v));} |
| 1887 | |
Eric Fiselier | a85b128 | 2017-04-18 21:08:06 +0000 | [diff] [blame] | 1888 | |
| 1889 | _LIBCPP_INLINE_VISIBILITY |
| 1890 | void insert(initializer_list<value_type> __il) |
| 1891 | {insert(__il.begin(), __il.end());} |
| 1892 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 1893 | #endif // _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1894 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1895 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1896 | iterator insert(const value_type& __v) {return __tree_.__insert_multi(__v);} |
| 1897 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1898 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1899 | iterator insert(const_iterator __p, const value_type& __v) |
| 1900 | {return __tree_.__insert_multi(__p.__i_, __v);} |
| 1901 | |
| 1902 | template <class _InputIterator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1903 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1904 | void insert(_InputIterator __f, _InputIterator __l) |
| 1905 | { |
| 1906 | for (const_iterator __e = cend(); __f != __l; ++__f) |
| 1907 | __tree_.__insert_multi(__e.__i_, *__f); |
| 1908 | } |
| 1909 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1910 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1911 | iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1912 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 22ea5b8 | 2015-05-10 13:35:00 +0000 | [diff] [blame] | 1913 | iterator erase(iterator __p) {return __tree_.erase(__p.__i_);} |
| 1914 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1915 | size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1916 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1917 | iterator erase(const_iterator __f, const_iterator __l) |
| 1918 | {return __tree_.erase(__f.__i_, __l.__i_);} |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1919 | |
| 1920 | #if _LIBCPP_STD_VER > 14 |
| 1921 | _LIBCPP_INLINE_VISIBILITY |
| 1922 | iterator insert(node_type&& __nh) |
| 1923 | { |
| 1924 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1925 | "node_type with incompatible allocator passed to multimap::insert()"); |
| 1926 | return __tree_.template __node_handle_insert_multi<node_type>( |
| 1927 | _VSTD::move(__nh)); |
| 1928 | } |
| 1929 | _LIBCPP_INLINE_VISIBILITY |
| 1930 | iterator insert(const_iterator __hint, node_type&& __nh) |
| 1931 | { |
| 1932 | _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1933 | "node_type with incompatible allocator passed to multimap::insert()"); |
| 1934 | return __tree_.template __node_handle_insert_multi<node_type>( |
| 1935 | __hint.__i_, _VSTD::move(__nh)); |
| 1936 | } |
| 1937 | _LIBCPP_INLINE_VISIBILITY |
| 1938 | node_type extract(key_type const& __key) |
| 1939 | { |
| 1940 | return __tree_.template __node_handle_extract<node_type>(__key); |
| 1941 | } |
| 1942 | _LIBCPP_INLINE_VISIBILITY |
| 1943 | node_type extract(const_iterator __it) |
| 1944 | { |
| 1945 | return __tree_.template __node_handle_extract<node_type>( |
| 1946 | __it.__i_); |
| 1947 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1948 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1949 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1950 | void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1951 | { |
| 1952 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1953 | "merging container with incompatible allocator"); |
| 1954 | return __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1955 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1956 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1957 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1958 | void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1959 | { |
| 1960 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1961 | "merging container with incompatible allocator"); |
| 1962 | return __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1963 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1964 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1965 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1966 | void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1967 | { |
| 1968 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1969 | "merging container with incompatible allocator"); |
| 1970 | return __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1971 | } |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1972 | template <class _Compare2> |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1973 | _LIBCPP_INLINE_VISIBILITY |
Louis Dionne | d2322c8 | 2018-11-01 14:41:37 +0000 | [diff] [blame] | 1974 | void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) |
Erik Pilkington | 82a65ad | 2018-10-31 17:31:35 +0000 | [diff] [blame] | 1975 | { |
| 1976 | _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(), |
| 1977 | "merging container with incompatible allocator"); |
| 1978 | return __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1979 | } |
Erik Pilkington | c37a3d8 | 2018-08-01 01:33:38 +0000 | [diff] [blame] | 1980 | #endif |
| 1981 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1982 | _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | de1312a | 2018-08-22 04:28:43 +0000 | [diff] [blame] | 1983 | void clear() _NOEXCEPT {__tree_.clear();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1984 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1985 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 1986 | void swap(multimap& __m) |
| 1987 | _NOEXCEPT_(__is_nothrow_swappable<__base>::value) |
| 1988 | {__tree_.swap(__m.__tree_);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1989 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1990 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1991 | iterator find(const key_type& __k) {return __tree_.find(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 1992 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1993 | const_iterator find(const key_type& __k) const {return __tree_.find(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 1994 | #if _LIBCPP_STD_VER > 11 |
| 1995 | template <typename _K2> |
| 1996 | _LIBCPP_INLINE_VISIBILITY |
| 1997 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 1998 | find(const _K2& __k) {return __tree_.find(__k);} |
| 1999 | template <typename _K2> |
| 2000 | _LIBCPP_INLINE_VISIBILITY |
| 2001 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 2002 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 2003 | #endif |
| 2004 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2005 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2006 | size_type count(const key_type& __k) const |
| 2007 | {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 2008 | #if _LIBCPP_STD_VER > 11 |
| 2009 | template <typename _K2> |
| 2010 | _LIBCPP_INLINE_VISIBILITY |
| 2011 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type |
Marshall Clow | 141e47b | 2015-06-30 18:15:41 +0000 | [diff] [blame] | 2012 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
Marshall Clow | e6a5f52 | 2014-08-24 23:54:16 +0000 | [diff] [blame] | 2013 | #endif |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2014 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2015 | iterator lower_bound(const key_type& __k) |
| 2016 | {return __tree_.lower_bound(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2017 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2018 | const_iterator lower_bound(const key_type& __k) const |
| 2019 | {return __tree_.lower_bound(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 2020 | #if _LIBCPP_STD_VER > 11 |
| 2021 | template <typename _K2> |
| 2022 | _LIBCPP_INLINE_VISIBILITY |
| 2023 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 2024 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 2025 | |
| 2026 | template <typename _K2> |
| 2027 | _LIBCPP_INLINE_VISIBILITY |
| 2028 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 2029 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 2030 | #endif |
| 2031 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2032 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2033 | iterator upper_bound(const key_type& __k) |
| 2034 | {return __tree_.upper_bound(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2035 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2036 | const_iterator upper_bound(const key_type& __k) const |
| 2037 | {return __tree_.upper_bound(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 2038 | #if _LIBCPP_STD_VER > 11 |
| 2039 | template <typename _K2> |
| 2040 | _LIBCPP_INLINE_VISIBILITY |
| 2041 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type |
| 2042 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 2043 | template <typename _K2> |
| 2044 | _LIBCPP_INLINE_VISIBILITY |
| 2045 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type |
| 2046 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 2047 | #endif |
| 2048 | |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2049 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2050 | pair<iterator,iterator> equal_range(const key_type& __k) |
| 2051 | {return __tree_.__equal_range_multi(__k);} |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2052 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2053 | pair<const_iterator,const_iterator> equal_range(const key_type& __k) const |
| 2054 | {return __tree_.__equal_range_multi(__k);} |
Marshall Clow | ebb5732 | 2013-08-13 22:18:47 +0000 | [diff] [blame] | 2055 | #if _LIBCPP_STD_VER > 11 |
| 2056 | template <typename _K2> |
| 2057 | _LIBCPP_INLINE_VISIBILITY |
| 2058 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type |
| 2059 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
| 2060 | template <typename _K2> |
| 2061 | _LIBCPP_INLINE_VISIBILITY |
| 2062 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type |
| 2063 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
| 2064 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2065 | |
| 2066 | private: |
| 2067 | typedef typename __base::__node __node; |
| 2068 | typedef typename __base::__node_allocator __node_allocator; |
| 2069 | typedef typename __base::__node_pointer __node_pointer; |
Eric Fiselier | a92b073 | 2016-02-20 07:12:17 +0000 | [diff] [blame] | 2070 | |
Howard Hinnant | c834c51 | 2011-11-29 18:15:50 +0000 | [diff] [blame] | 2071 | typedef __map_node_destructor<__node_allocator> _Dp; |
| 2072 | typedef unique_ptr<__node, _Dp> __node_holder; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2073 | }; |
| 2074 | |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 2075 | #ifndef _LIBCPP_CXX03_LANG |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2076 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 2077 | multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a) |
Marshall Clow | 657cbc4 | 2016-08-17 05:58:40 +0000 | [diff] [blame] | 2078 | : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a)) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2079 | { |
| 2080 | if (__a != __m.get_allocator()) |
| 2081 | { |
| 2082 | const_iterator __e = cend(); |
| 2083 | while (!__m.empty()) |
| 2084 | __tree_.__insert_multi(__e.__i_, |
Erik Pilkington | d3fe299 | 2018-06-04 20:38:23 +0000 | [diff] [blame] | 2085 | _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move())); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2086 | } |
| 2087 | } |
Eric Fiselier | d06276b | 2016-03-31 02:15:15 +0000 | [diff] [blame] | 2088 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2089 | |
| 2090 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2091 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2092 | bool |
| 2093 | operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2094 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2095 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2096 | 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] | 2097 | } |
| 2098 | |
| 2099 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2100 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2101 | bool |
| 2102 | operator< (const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2103 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2104 | { |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 2105 | return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2106 | } |
| 2107 | |
| 2108 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2109 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2110 | bool |
| 2111 | operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2112 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2113 | { |
| 2114 | return !(__x == __y); |
| 2115 | } |
| 2116 | |
| 2117 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2118 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2119 | bool |
| 2120 | operator> (const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2121 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2122 | { |
| 2123 | return __y < __x; |
| 2124 | } |
| 2125 | |
| 2126 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2127 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2128 | bool |
| 2129 | operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2130 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2131 | { |
| 2132 | return !(__x < __y); |
| 2133 | } |
| 2134 | |
| 2135 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2136 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2137 | bool |
| 2138 | operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2139 | const multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
| 2140 | { |
| 2141 | return !(__y < __x); |
| 2142 | } |
| 2143 | |
| 2144 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
Howard Hinnant | 756c69b | 2010-09-22 16:48:34 +0000 | [diff] [blame] | 2145 | inline _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2146 | void |
| 2147 | swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2148 | multimap<_Key, _Tp, _Compare, _Allocator>& __y) |
Howard Hinnant | 2f1ea9c | 2011-06-04 14:31:57 +0000 | [diff] [blame] | 2149 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 2150 | { |
| 2151 | __x.swap(__y); |
| 2152 | } |
| 2153 | |
| 2154 | _LIBCPP_END_NAMESPACE_STD |
| 2155 | |
| 2156 | #endif // _LIBCPP_MAP |