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