libstdc++
|
00001 // Debugging map implementation -*- C++ -*- 00002 00003 // Copyright (C) 2003-2018 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file debug/map.h 00026 * This file is a GNU debug extension to the Standard C++ Library. 00027 */ 00028 00029 #ifndef _GLIBCXX_DEBUG_MAP_H 00030 #define _GLIBCXX_DEBUG_MAP_H 1 00031 00032 #include <debug/safe_sequence.h> 00033 #include <debug/safe_container.h> 00034 #include <debug/safe_iterator.h> 00035 #include <utility> 00036 00037 namespace std _GLIBCXX_VISIBILITY(default) 00038 { 00039 namespace __debug 00040 { 00041 /// Class std::map with safety/checking/debug instrumentation. 00042 template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>, 00043 typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > > 00044 class map 00045 : public __gnu_debug::_Safe_container< 00046 map<_Key, _Tp, _Compare, _Allocator>, _Allocator, 00047 __gnu_debug::_Safe_node_sequence>, 00048 public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator> 00049 { 00050 typedef _GLIBCXX_STD_C::map< 00051 _Key, _Tp, _Compare, _Allocator> _Base; 00052 typedef __gnu_debug::_Safe_container< 00053 map, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe; 00054 00055 typedef typename _Base::const_iterator _Base_const_iterator; 00056 typedef typename _Base::iterator _Base_iterator; 00057 typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal; 00058 00059 public: 00060 // types: 00061 typedef _Key key_type; 00062 typedef _Tp mapped_type; 00063 typedef std::pair<const _Key, _Tp> value_type; 00064 typedef _Compare key_compare; 00065 typedef _Allocator allocator_type; 00066 typedef typename _Base::reference reference; 00067 typedef typename _Base::const_reference const_reference; 00068 00069 typedef __gnu_debug::_Safe_iterator<_Base_iterator, map> 00070 iterator; 00071 typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, map> 00072 const_iterator; 00073 00074 typedef typename _Base::size_type size_type; 00075 typedef typename _Base::difference_type difference_type; 00076 typedef typename _Base::pointer pointer; 00077 typedef typename _Base::const_pointer const_pointer; 00078 typedef std::reverse_iterator<iterator> reverse_iterator; 00079 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 00080 00081 // 23.3.1.1 construct/copy/destroy: 00082 00083 #if __cplusplus < 201103L 00084 map() : _Base() { } 00085 00086 map(const map& __x) 00087 : _Base(__x) { } 00088 00089 ~map() { } 00090 #else 00091 map() = default; 00092 map(const map&) = default; 00093 map(map&&) = default; 00094 00095 map(initializer_list<value_type> __l, 00096 const _Compare& __c = _Compare(), 00097 const allocator_type& __a = allocator_type()) 00098 : _Base(__l, __c, __a) { } 00099 00100 explicit 00101 map(const allocator_type& __a) 00102 : _Base(__a) { } 00103 00104 map(const map& __m, const allocator_type& __a) 00105 : _Base(__m, __a) { } 00106 00107 map(map&& __m, const allocator_type& __a) 00108 noexcept( noexcept(_Base(std::move(__m._M_base()), __a)) ) 00109 : _Safe(std::move(__m._M_safe()), __a), 00110 _Base(std::move(__m._M_base()), __a) { } 00111 00112 map(initializer_list<value_type> __l, const allocator_type& __a) 00113 : _Base(__l, __a) { } 00114 00115 template<typename _InputIterator> 00116 map(_InputIterator __first, _InputIterator __last, 00117 const allocator_type& __a) 00118 : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first, 00119 __last)), 00120 __gnu_debug::__base(__last), __a) 00121 { } 00122 00123 ~map() = default; 00124 #endif 00125 00126 map(const _Base& __x) 00127 : _Base(__x) { } 00128 00129 explicit map(const _Compare& __comp, 00130 const _Allocator& __a = _Allocator()) 00131 : _Base(__comp, __a) { } 00132 00133 template<typename _InputIterator> 00134 map(_InputIterator __first, _InputIterator __last, 00135 const _Compare& __comp = _Compare(), 00136 const _Allocator& __a = _Allocator()) 00137 : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__first, 00138 __last)), 00139 __gnu_debug::__base(__last), 00140 __comp, __a) { } 00141 00142 #if __cplusplus < 201103L 00143 map& 00144 operator=(const map& __x) 00145 { 00146 this->_M_safe() = __x; 00147 _M_base() = __x; 00148 return *this; 00149 } 00150 #else 00151 map& 00152 operator=(const map&) = default; 00153 00154 map& 00155 operator=(map&&) = default; 00156 00157 map& 00158 operator=(initializer_list<value_type> __l) 00159 { 00160 _M_base() = __l; 00161 this->_M_invalidate_all(); 00162 return *this; 00163 } 00164 #endif 00165 00166 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00167 // 133. map missing get_allocator() 00168 using _Base::get_allocator; 00169 00170 // iterators: 00171 iterator 00172 begin() _GLIBCXX_NOEXCEPT 00173 { return iterator(_Base::begin(), this); } 00174 00175 const_iterator 00176 begin() const _GLIBCXX_NOEXCEPT 00177 { return const_iterator(_Base::begin(), this); } 00178 00179 iterator 00180 end() _GLIBCXX_NOEXCEPT 00181 { return iterator(_Base::end(), this); } 00182 00183 const_iterator 00184 end() const _GLIBCXX_NOEXCEPT 00185 { return const_iterator(_Base::end(), this); } 00186 00187 reverse_iterator 00188 rbegin() _GLIBCXX_NOEXCEPT 00189 { return reverse_iterator(end()); } 00190 00191 const_reverse_iterator 00192 rbegin() const _GLIBCXX_NOEXCEPT 00193 { return const_reverse_iterator(end()); } 00194 00195 reverse_iterator 00196 rend() _GLIBCXX_NOEXCEPT 00197 { return reverse_iterator(begin()); } 00198 00199 const_reverse_iterator 00200 rend() const _GLIBCXX_NOEXCEPT 00201 { return const_reverse_iterator(begin()); } 00202 00203 #if __cplusplus >= 201103L 00204 const_iterator 00205 cbegin() const noexcept 00206 { return const_iterator(_Base::begin(), this); } 00207 00208 const_iterator 00209 cend() const noexcept 00210 { return const_iterator(_Base::end(), this); } 00211 00212 const_reverse_iterator 00213 crbegin() const noexcept 00214 { return const_reverse_iterator(end()); } 00215 00216 const_reverse_iterator 00217 crend() const noexcept 00218 { return const_reverse_iterator(begin()); } 00219 #endif 00220 00221 // capacity: 00222 using _Base::empty; 00223 using _Base::size; 00224 using _Base::max_size; 00225 00226 // 23.3.1.2 element access: 00227 using _Base::operator[]; 00228 00229 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00230 // DR 464. Suggestion for new member functions in standard containers. 00231 using _Base::at; 00232 00233 // modifiers: 00234 #if __cplusplus >= 201103L 00235 template<typename... _Args> 00236 std::pair<iterator, bool> 00237 emplace(_Args&&... __args) 00238 { 00239 auto __res = _Base::emplace(std::forward<_Args>(__args)...); 00240 return std::pair<iterator, bool>(iterator(__res.first, this), 00241 __res.second); 00242 } 00243 00244 template<typename... _Args> 00245 iterator 00246 emplace_hint(const_iterator __pos, _Args&&... __args) 00247 { 00248 __glibcxx_check_insert(__pos); 00249 return iterator(_Base::emplace_hint(__pos.base(), 00250 std::forward<_Args>(__args)...), 00251 this); 00252 } 00253 #endif 00254 00255 std::pair<iterator, bool> 00256 insert(const value_type& __x) 00257 { 00258 std::pair<_Base_iterator, bool> __res = _Base::insert(__x); 00259 return std::pair<iterator, bool>(iterator(__res.first, this), 00260 __res.second); 00261 } 00262 00263 #if __cplusplus >= 201103L 00264 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00265 // 2354. Unnecessary copying when inserting into maps with braced-init 00266 std::pair<iterator, bool> 00267 insert(value_type&& __x) 00268 { 00269 auto __res = _Base::insert(std::move(__x)); 00270 return { iterator(__res.first, this), __res.second }; 00271 } 00272 00273 template<typename _Pair, typename = typename 00274 std::enable_if<std::is_constructible<value_type, 00275 _Pair&&>::value>::type> 00276 std::pair<iterator, bool> 00277 insert(_Pair&& __x) 00278 { 00279 std::pair<_Base_iterator, bool> __res 00280 = _Base::insert(std::forward<_Pair>(__x)); 00281 return std::pair<iterator, bool>(iterator(__res.first, this), 00282 __res.second); 00283 } 00284 #endif 00285 00286 #if __cplusplus >= 201103L 00287 void 00288 insert(std::initializer_list<value_type> __list) 00289 { _Base::insert(__list); } 00290 #endif 00291 00292 iterator 00293 #if __cplusplus >= 201103L 00294 insert(const_iterator __position, const value_type& __x) 00295 #else 00296 insert(iterator __position, const value_type& __x) 00297 #endif 00298 { 00299 __glibcxx_check_insert(__position); 00300 return iterator(_Base::insert(__position.base(), __x), this); 00301 } 00302 00303 #if __cplusplus >= 201103L 00304 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00305 // 2354. Unnecessary copying when inserting into maps with braced-init 00306 iterator 00307 insert(const_iterator __position, value_type&& __x) 00308 { 00309 __glibcxx_check_insert(__position); 00310 return { _Base::insert(__position.base(), std::move(__x)), this }; 00311 } 00312 00313 template<typename _Pair, typename = typename 00314 std::enable_if<std::is_constructible<value_type, 00315 _Pair&&>::value>::type> 00316 iterator 00317 insert(const_iterator __position, _Pair&& __x) 00318 { 00319 __glibcxx_check_insert(__position); 00320 return iterator(_Base::insert(__position.base(), 00321 std::forward<_Pair>(__x)), this); 00322 } 00323 #endif 00324 00325 template<typename _InputIterator> 00326 void 00327 insert(_InputIterator __first, _InputIterator __last) 00328 { 00329 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; 00330 __glibcxx_check_valid_range2(__first, __last, __dist); 00331 00332 if (__dist.second >= __gnu_debug::__dp_sign) 00333 _Base::insert(__gnu_debug::__unsafe(__first), 00334 __gnu_debug::__unsafe(__last)); 00335 else 00336 _Base::insert(__first, __last); 00337 } 00338 00339 00340 #if __cplusplus > 201402L 00341 template <typename... _Args> 00342 pair<iterator, bool> 00343 try_emplace(const key_type& __k, _Args&&... __args) 00344 { 00345 auto __res = _Base::try_emplace(__k, 00346 std::forward<_Args>(__args)...); 00347 return { iterator(__res.first, this), __res.second }; 00348 } 00349 00350 template <typename... _Args> 00351 pair<iterator, bool> 00352 try_emplace(key_type&& __k, _Args&&... __args) 00353 { 00354 auto __res = _Base::try_emplace(std::move(__k), 00355 std::forward<_Args>(__args)...); 00356 return { iterator(__res.first, this), __res.second }; 00357 } 00358 00359 template <typename... _Args> 00360 iterator 00361 try_emplace(const_iterator __hint, const key_type& __k, 00362 _Args&&... __args) 00363 { 00364 __glibcxx_check_insert(__hint); 00365 return iterator(_Base::try_emplace(__hint.base(), __k, 00366 std::forward<_Args>(__args)...), 00367 this); 00368 } 00369 00370 template <typename... _Args> 00371 iterator 00372 try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args) 00373 { 00374 __glibcxx_check_insert(__hint); 00375 return iterator(_Base::try_emplace(__hint.base(), std::move(__k), 00376 std::forward<_Args>(__args)...), 00377 this); 00378 } 00379 00380 template <typename _Obj> 00381 std::pair<iterator, bool> 00382 insert_or_assign(const key_type& __k, _Obj&& __obj) 00383 { 00384 auto __res = _Base::insert_or_assign(__k, 00385 std::forward<_Obj>(__obj)); 00386 return { iterator(__res.first, this), __res.second }; 00387 } 00388 00389 template <typename _Obj> 00390 std::pair<iterator, bool> 00391 insert_or_assign(key_type&& __k, _Obj&& __obj) 00392 { 00393 auto __res = _Base::insert_or_assign(std::move(__k), 00394 std::forward<_Obj>(__obj)); 00395 return { iterator(__res.first, this), __res.second }; 00396 } 00397 00398 template <typename _Obj> 00399 iterator 00400 insert_or_assign(const_iterator __hint, 00401 const key_type& __k, _Obj&& __obj) 00402 { 00403 __glibcxx_check_insert(__hint); 00404 return iterator(_Base::insert_or_assign(__hint.base(), __k, 00405 std::forward<_Obj>(__obj)), 00406 this); 00407 } 00408 00409 template <typename _Obj> 00410 iterator 00411 insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj) 00412 { 00413 __glibcxx_check_insert(__hint); 00414 return iterator(_Base::insert_or_assign(__hint.base(), 00415 std::move(__k), 00416 std::forward<_Obj>(__obj)), 00417 this); 00418 } 00419 #endif // C++17 00420 00421 #if __cplusplus > 201402L 00422 using node_type = typename _Base::node_type; 00423 using insert_return_type = _Node_insert_return<iterator, node_type>; 00424 00425 node_type 00426 extract(const_iterator __position) 00427 { 00428 __glibcxx_check_erase(__position); 00429 this->_M_invalidate_if(_Equal(__position.base())); 00430 return _Base::extract(__position.base()); 00431 } 00432 00433 node_type 00434 extract(const key_type& __key) 00435 { 00436 const auto __position = find(__key); 00437 if (__position != end()) 00438 return extract(__position); 00439 return {}; 00440 } 00441 00442 insert_return_type 00443 insert(node_type&& __nh) 00444 { 00445 auto __ret = _Base::insert(std::move(__nh)); 00446 iterator __pos = iterator(__ret.position, this); 00447 return { __pos, __ret.inserted, std::move(__ret.node) }; 00448 } 00449 00450 iterator 00451 insert(const_iterator __hint, node_type&& __nh) 00452 { 00453 __glibcxx_check_insert(__hint); 00454 return iterator(_Base::insert(__hint.base(), std::move(__nh)), this); 00455 } 00456 00457 using _Base::merge; 00458 #endif // C++17 00459 00460 #if __cplusplus >= 201103L 00461 iterator 00462 erase(const_iterator __position) 00463 { 00464 __glibcxx_check_erase(__position); 00465 this->_M_invalidate_if(_Equal(__position.base())); 00466 return iterator(_Base::erase(__position.base()), this); 00467 } 00468 00469 iterator 00470 erase(iterator __position) 00471 { return erase(const_iterator(__position)); } 00472 #else 00473 void 00474 erase(iterator __position) 00475 { 00476 __glibcxx_check_erase(__position); 00477 this->_M_invalidate_if(_Equal(__position.base())); 00478 _Base::erase(__position.base()); 00479 } 00480 #endif 00481 00482 size_type 00483 erase(const key_type& __x) 00484 { 00485 _Base_iterator __victim = _Base::find(__x); 00486 if (__victim == _Base::end()) 00487 return 0; 00488 else 00489 { 00490 this->_M_invalidate_if(_Equal(__victim)); 00491 _Base::erase(__victim); 00492 return 1; 00493 } 00494 } 00495 00496 #if __cplusplus >= 201103L 00497 iterator 00498 erase(const_iterator __first, const_iterator __last) 00499 { 00500 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00501 // 151. can't currently clear() empty container 00502 __glibcxx_check_erase_range(__first, __last); 00503 for (_Base_const_iterator __victim = __first.base(); 00504 __victim != __last.base(); ++__victim) 00505 { 00506 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), 00507 _M_message(__gnu_debug::__msg_valid_range) 00508 ._M_iterator(__first, "first") 00509 ._M_iterator(__last, "last")); 00510 this->_M_invalidate_if(_Equal(__victim)); 00511 } 00512 return iterator(_Base::erase(__first.base(), __last.base()), this); 00513 } 00514 #else 00515 void 00516 erase(iterator __first, iterator __last) 00517 { 00518 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00519 // 151. can't currently clear() empty container 00520 __glibcxx_check_erase_range(__first, __last); 00521 for (_Base_iterator __victim = __first.base(); 00522 __victim != __last.base(); ++__victim) 00523 { 00524 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), 00525 _M_message(__gnu_debug::__msg_valid_range) 00526 ._M_iterator(__first, "first") 00527 ._M_iterator(__last, "last")); 00528 this->_M_invalidate_if(_Equal(__victim)); 00529 } 00530 _Base::erase(__first.base(), __last.base()); 00531 } 00532 #endif 00533 00534 void 00535 swap(map& __x) 00536 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) 00537 { 00538 _Safe::_M_swap(__x); 00539 _Base::swap(__x); 00540 } 00541 00542 void 00543 clear() _GLIBCXX_NOEXCEPT 00544 { 00545 this->_M_invalidate_all(); 00546 _Base::clear(); 00547 } 00548 00549 // observers: 00550 using _Base::key_comp; 00551 using _Base::value_comp; 00552 00553 // 23.3.1.3 map operations: 00554 iterator 00555 find(const key_type& __x) 00556 { return iterator(_Base::find(__x), this); } 00557 00558 #if __cplusplus > 201103L 00559 template<typename _Kt, 00560 typename _Req = 00561 typename __has_is_transparent<_Compare, _Kt>::type> 00562 iterator 00563 find(const _Kt& __x) 00564 { return { _Base::find(__x), this }; } 00565 #endif 00566 00567 const_iterator 00568 find(const key_type& __x) const 00569 { return const_iterator(_Base::find(__x), this); } 00570 00571 #if __cplusplus > 201103L 00572 template<typename _Kt, 00573 typename _Req = 00574 typename __has_is_transparent<_Compare, _Kt>::type> 00575 const_iterator 00576 find(const _Kt& __x) const 00577 { return { _Base::find(__x), this }; } 00578 #endif 00579 00580 using _Base::count; 00581 00582 iterator 00583 lower_bound(const key_type& __x) 00584 { return iterator(_Base::lower_bound(__x), this); } 00585 00586 #if __cplusplus > 201103L 00587 template<typename _Kt, 00588 typename _Req = 00589 typename __has_is_transparent<_Compare, _Kt>::type> 00590 iterator 00591 lower_bound(const _Kt& __x) 00592 { return { _Base::lower_bound(__x), this }; } 00593 #endif 00594 00595 const_iterator 00596 lower_bound(const key_type& __x) const 00597 { return const_iterator(_Base::lower_bound(__x), this); } 00598 00599 #if __cplusplus > 201103L 00600 template<typename _Kt, 00601 typename _Req = 00602 typename __has_is_transparent<_Compare, _Kt>::type> 00603 const_iterator 00604 lower_bound(const _Kt& __x) const 00605 { return { _Base::lower_bound(__x), this }; } 00606 #endif 00607 00608 iterator 00609 upper_bound(const key_type& __x) 00610 { return iterator(_Base::upper_bound(__x), this); } 00611 00612 #if __cplusplus > 201103L 00613 template<typename _Kt, 00614 typename _Req = 00615 typename __has_is_transparent<_Compare, _Kt>::type> 00616 iterator 00617 upper_bound(const _Kt& __x) 00618 { return { _Base::upper_bound(__x), this }; } 00619 #endif 00620 00621 const_iterator 00622 upper_bound(const key_type& __x) const 00623 { return const_iterator(_Base::upper_bound(__x), this); } 00624 00625 #if __cplusplus > 201103L 00626 template<typename _Kt, 00627 typename _Req = 00628 typename __has_is_transparent<_Compare, _Kt>::type> 00629 const_iterator 00630 upper_bound(const _Kt& __x) const 00631 { return { _Base::upper_bound(__x), this }; } 00632 #endif 00633 00634 std::pair<iterator,iterator> 00635 equal_range(const key_type& __x) 00636 { 00637 std::pair<_Base_iterator, _Base_iterator> __res = 00638 _Base::equal_range(__x); 00639 return std::make_pair(iterator(__res.first, this), 00640 iterator(__res.second, this)); 00641 } 00642 00643 #if __cplusplus > 201103L 00644 template<typename _Kt, 00645 typename _Req = 00646 typename __has_is_transparent<_Compare, _Kt>::type> 00647 std::pair<iterator, iterator> 00648 equal_range(const _Kt& __x) 00649 { 00650 auto __res = _Base::equal_range(__x); 00651 return { { __res.first, this }, { __res.second, this } }; 00652 } 00653 #endif 00654 00655 std::pair<const_iterator,const_iterator> 00656 equal_range(const key_type& __x) const 00657 { 00658 std::pair<_Base_const_iterator, _Base_const_iterator> __res = 00659 _Base::equal_range(__x); 00660 return std::make_pair(const_iterator(__res.first, this), 00661 const_iterator(__res.second, this)); 00662 } 00663 00664 #if __cplusplus > 201103L 00665 template<typename _Kt, 00666 typename _Req = 00667 typename __has_is_transparent<_Compare, _Kt>::type> 00668 std::pair<const_iterator, const_iterator> 00669 equal_range(const _Kt& __x) const 00670 { 00671 auto __res = _Base::equal_range(__x); 00672 return { { __res.first, this }, { __res.second, this } }; 00673 } 00674 #endif 00675 00676 _Base& 00677 _M_base() _GLIBCXX_NOEXCEPT { return *this; } 00678 00679 const _Base& 00680 _M_base() const _GLIBCXX_NOEXCEPT { return *this; } 00681 }; 00682 00683 #if __cpp_deduction_guides >= 201606 00684 00685 template<typename _InputIterator, 00686 typename _Compare = less<__iter_key_t<_InputIterator>>, 00687 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, 00688 typename = _RequireInputIter<_InputIterator>, 00689 typename = _RequireAllocator<_Allocator>> 00690 map(_InputIterator, _InputIterator, 00691 _Compare = _Compare(), _Allocator = _Allocator()) 00692 -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, 00693 _Compare, _Allocator>; 00694 00695 template<typename _Key, typename _Tp, typename _Compare = less<_Key>, 00696 typename _Allocator = allocator<pair<const _Key, _Tp>>, 00697 typename = _RequireAllocator<_Allocator>> 00698 map(initializer_list<pair<_Key, _Tp>>, 00699 _Compare = _Compare(), _Allocator = _Allocator()) 00700 -> map<_Key, _Tp, _Compare, _Allocator>; 00701 00702 template <typename _InputIterator, typename _Allocator, 00703 typename = _RequireInputIter<_InputIterator>, 00704 typename = _RequireAllocator<_Allocator>> 00705 map(_InputIterator, _InputIterator, _Allocator) 00706 -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, 00707 less<__iter_key_t<_InputIterator>>, _Allocator>; 00708 00709 template<typename _Key, typename _Tp, typename _Allocator, 00710 typename = _RequireAllocator<_Allocator>> 00711 map(initializer_list<pair<_Key, _Tp>>, _Allocator) 00712 -> map<_Key, _Tp, less<_Key>, _Allocator>; 00713 00714 #endif 00715 00716 template<typename _Key, typename _Tp, 00717 typename _Compare, typename _Allocator> 00718 inline bool 00719 operator==(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, 00720 const map<_Key, _Tp, _Compare, _Allocator>& __rhs) 00721 { return __lhs._M_base() == __rhs._M_base(); } 00722 00723 template<typename _Key, typename _Tp, 00724 typename _Compare, typename _Allocator> 00725 inline bool 00726 operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, 00727 const map<_Key, _Tp, _Compare, _Allocator>& __rhs) 00728 { return __lhs._M_base() != __rhs._M_base(); } 00729 00730 template<typename _Key, typename _Tp, 00731 typename _Compare, typename _Allocator> 00732 inline bool 00733 operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, 00734 const map<_Key, _Tp, _Compare, _Allocator>& __rhs) 00735 { return __lhs._M_base() < __rhs._M_base(); } 00736 00737 template<typename _Key, typename _Tp, 00738 typename _Compare, typename _Allocator> 00739 inline bool 00740 operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, 00741 const map<_Key, _Tp, _Compare, _Allocator>& __rhs) 00742 { return __lhs._M_base() <= __rhs._M_base(); } 00743 00744 template<typename _Key, typename _Tp, 00745 typename _Compare, typename _Allocator> 00746 inline bool 00747 operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, 00748 const map<_Key, _Tp, _Compare, _Allocator>& __rhs) 00749 { return __lhs._M_base() >= __rhs._M_base(); } 00750 00751 template<typename _Key, typename _Tp, 00752 typename _Compare, typename _Allocator> 00753 inline bool 00754 operator>(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, 00755 const map<_Key, _Tp, _Compare, _Allocator>& __rhs) 00756 { return __lhs._M_base() > __rhs._M_base(); } 00757 00758 template<typename _Key, typename _Tp, 00759 typename _Compare, typename _Allocator> 00760 inline void 00761 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs, 00762 map<_Key, _Tp, _Compare, _Allocator>& __rhs) 00763 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) 00764 { __lhs.swap(__rhs); } 00765 00766 } // namespace __debug 00767 } // namespace std 00768 00769 #endif