set.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. // Debugging set implementation -*- C++ -*-
  2. // Copyright (C) 2003-2021 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file debug/set.h
  21. * This file is a GNU debug extension to the Standard C++ Library.
  22. */
  23. #ifndef _GLIBCXX_DEBUG_SET_H
  24. #define _GLIBCXX_DEBUG_SET_H 1
  25. #include <debug/safe_sequence.h>
  26. #include <debug/safe_container.h>
  27. #include <debug/safe_iterator.h>
  28. #include <utility>
  29. namespace std _GLIBCXX_VISIBILITY(default)
  30. {
  31. namespace __debug
  32. {
  33. /// Class std::set with safety/checking/debug instrumentation.
  34. template<typename _Key, typename _Compare = std::less<_Key>,
  35. typename _Allocator = std::allocator<_Key> >
  36. class set
  37. : public __gnu_debug::_Safe_container<
  38. set<_Key, _Compare, _Allocator>, _Allocator,
  39. __gnu_debug::_Safe_node_sequence>,
  40. public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator>
  41. {
  42. typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base;
  43. typedef __gnu_debug::_Safe_container<
  44. set, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe;
  45. typedef typename _Base::const_iterator _Base_const_iterator;
  46. typedef typename _Base::iterator _Base_iterator;
  47. typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal;
  48. template<typename _ItT, typename _SeqT, typename _CatT>
  49. friend class ::__gnu_debug::_Safe_iterator;
  50. // Reference wrapper for base class. Disambiguates set(const _Base&)
  51. // from copy constructor by requiring a user-defined conversion.
  52. // See PR libstdc++/90102.
  53. struct _Base_ref
  54. {
  55. _Base_ref(const _Base& __r) : _M_ref(__r) { }
  56. const _Base& _M_ref;
  57. };
  58. public:
  59. // types:
  60. typedef _Key key_type;
  61. typedef _Key value_type;
  62. typedef _Compare key_compare;
  63. typedef _Compare value_compare;
  64. typedef _Allocator allocator_type;
  65. typedef typename _Base::reference reference;
  66. typedef typename _Base::const_reference const_reference;
  67. typedef __gnu_debug::_Safe_iterator<_Base_iterator, set>
  68. iterator;
  69. typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, set>
  70. const_iterator;
  71. typedef typename _Base::size_type size_type;
  72. typedef typename _Base::difference_type difference_type;
  73. typedef typename _Base::pointer pointer;
  74. typedef typename _Base::const_pointer const_pointer;
  75. typedef std::reverse_iterator<iterator> reverse_iterator;
  76. typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
  77. // 23.3.3.1 construct/copy/destroy:
  78. #if __cplusplus < 201103L
  79. set() : _Base() { }
  80. set(const set& __x)
  81. : _Base(__x) { }
  82. ~set() { }
  83. #else
  84. set() = default;
  85. set(const set&) = default;
  86. set(set&&) = default;
  87. set(initializer_list<value_type> __l,
  88. const _Compare& __comp = _Compare(),
  89. const allocator_type& __a = allocator_type())
  90. : _Base(__l, __comp, __a) { }
  91. explicit
  92. set(const allocator_type& __a)
  93. : _Base(__a) { }
  94. set(const set& __x, const allocator_type& __a)
  95. : _Base(__x, __a) { }
  96. set(set&& __x, const allocator_type& __a)
  97. noexcept( noexcept(_Base(std::move(__x._M_base()), __a)) )
  98. : _Safe(std::move(__x._M_safe()), __a),
  99. _Base(std::move(__x._M_base()), __a) { }
  100. set(initializer_list<value_type> __l, const allocator_type& __a)
  101. : _Base(__l, __a) { }
  102. template<typename _InputIterator>
  103. set(_InputIterator __first, _InputIterator __last,
  104. const allocator_type& __a)
  105. : _Base(__gnu_debug::__base(
  106. __glibcxx_check_valid_constructor_range(__first, __last)),
  107. __gnu_debug::__base(__last), __a) { }
  108. ~set() = default;
  109. #endif
  110. explicit set(const _Compare& __comp,
  111. const _Allocator& __a = _Allocator())
  112. : _Base(__comp, __a) { }
  113. template<typename _InputIterator>
  114. set(_InputIterator __first, _InputIterator __last,
  115. const _Compare& __comp = _Compare(),
  116. const _Allocator& __a = _Allocator())
  117. : _Base(__gnu_debug::__base(
  118. __glibcxx_check_valid_constructor_range(__first, __last)),
  119. __gnu_debug::__base(__last),
  120. __comp, __a) { }
  121. set(_Base_ref __x)
  122. : _Base(__x._M_ref) { }
  123. #if __cplusplus < 201103L
  124. set&
  125. operator=(const set& __x)
  126. {
  127. this->_M_safe() = __x;
  128. _M_base() = __x;
  129. return *this;
  130. }
  131. #else
  132. set&
  133. operator=(const set&) = default;
  134. set&
  135. operator=(set&&) = default;
  136. set&
  137. operator=(initializer_list<value_type> __l)
  138. {
  139. _M_base() = __l;
  140. this->_M_invalidate_all();
  141. return *this;
  142. }
  143. #endif
  144. using _Base::get_allocator;
  145. // iterators:
  146. iterator
  147. begin() _GLIBCXX_NOEXCEPT
  148. { return iterator(_Base::begin(), this); }
  149. const_iterator
  150. begin() const _GLIBCXX_NOEXCEPT
  151. { return const_iterator(_Base::begin(), this); }
  152. iterator
  153. end() _GLIBCXX_NOEXCEPT
  154. { return iterator(_Base::end(), this); }
  155. const_iterator
  156. end() const _GLIBCXX_NOEXCEPT
  157. { return const_iterator(_Base::end(), this); }
  158. reverse_iterator
  159. rbegin() _GLIBCXX_NOEXCEPT
  160. { return reverse_iterator(end()); }
  161. const_reverse_iterator
  162. rbegin() const _GLIBCXX_NOEXCEPT
  163. { return const_reverse_iterator(end()); }
  164. reverse_iterator
  165. rend() _GLIBCXX_NOEXCEPT
  166. { return reverse_iterator(begin()); }
  167. const_reverse_iterator
  168. rend() const _GLIBCXX_NOEXCEPT
  169. { return const_reverse_iterator(begin()); }
  170. #if __cplusplus >= 201103L
  171. const_iterator
  172. cbegin() const noexcept
  173. { return const_iterator(_Base::begin(), this); }
  174. const_iterator
  175. cend() const noexcept
  176. { return const_iterator(_Base::end(), this); }
  177. const_reverse_iterator
  178. crbegin() const noexcept
  179. { return const_reverse_iterator(end()); }
  180. const_reverse_iterator
  181. crend() const noexcept
  182. { return const_reverse_iterator(begin()); }
  183. #endif
  184. // capacity:
  185. using _Base::empty;
  186. using _Base::size;
  187. using _Base::max_size;
  188. // modifiers:
  189. #if __cplusplus >= 201103L
  190. template<typename... _Args>
  191. std::pair<iterator, bool>
  192. emplace(_Args&&... __args)
  193. {
  194. auto __res = _Base::emplace(std::forward<_Args>(__args)...);
  195. return { { __res.first, this }, __res.second };
  196. }
  197. template<typename... _Args>
  198. iterator
  199. emplace_hint(const_iterator __pos, _Args&&... __args)
  200. {
  201. __glibcxx_check_insert(__pos);
  202. return
  203. {
  204. _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...),
  205. this
  206. };
  207. }
  208. #endif
  209. std::pair<iterator, bool>
  210. insert(const value_type& __x)
  211. {
  212. std::pair<_Base_iterator, bool> __res = _Base::insert(__x);
  213. return std::pair<iterator, bool>(iterator(__res.first, this),
  214. __res.second);
  215. }
  216. #if __cplusplus >= 201103L
  217. std::pair<iterator, bool>
  218. insert(value_type&& __x)
  219. {
  220. auto __res = _Base::insert(std::move(__x));
  221. return { { __res.first, this }, __res.second };
  222. }
  223. #endif
  224. iterator
  225. insert(const_iterator __position, const value_type& __x)
  226. {
  227. __glibcxx_check_insert(__position);
  228. return iterator(_Base::insert(__position.base(), __x), this);
  229. }
  230. #if __cplusplus >= 201103L
  231. iterator
  232. insert(const_iterator __position, value_type&& __x)
  233. {
  234. __glibcxx_check_insert(__position);
  235. return { _Base::insert(__position.base(), std::move(__x)), this };
  236. }
  237. #endif
  238. template <typename _InputIterator>
  239. void
  240. insert(_InputIterator __first, _InputIterator __last)
  241. {
  242. typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
  243. __glibcxx_check_valid_range2(__first, __last, __dist);
  244. if (__dist.second >= __gnu_debug::__dp_sign)
  245. _Base::insert(__gnu_debug::__unsafe(__first),
  246. __gnu_debug::__unsafe(__last));
  247. else
  248. _Base::insert(__first, __last);
  249. }
  250. #if __cplusplus >= 201103L
  251. void
  252. insert(initializer_list<value_type> __l)
  253. { _Base::insert(__l); }
  254. #endif
  255. #if __cplusplus > 201402L
  256. using node_type = typename _Base::node_type;
  257. using insert_return_type = _Node_insert_return<iterator, node_type>;
  258. node_type
  259. extract(const_iterator __position)
  260. {
  261. __glibcxx_check_erase(__position);
  262. this->_M_invalidate_if(_Equal(__position.base()));
  263. return _Base::extract(__position.base());
  264. }
  265. node_type
  266. extract(const key_type& __key)
  267. {
  268. const auto __position = find(__key);
  269. if (__position != end())
  270. return extract(__position);
  271. return {};
  272. }
  273. insert_return_type
  274. insert(node_type&& __nh)
  275. {
  276. auto __ret = _Base::insert(std::move(__nh));
  277. iterator __pos = iterator(__ret.position, this);
  278. return { __pos, __ret.inserted, std::move(__ret.node) };
  279. }
  280. iterator
  281. insert(const_iterator __hint, node_type&& __nh)
  282. {
  283. __glibcxx_check_insert(__hint);
  284. return { _Base::insert(__hint.base(), std::move(__nh)), this };
  285. }
  286. using _Base::merge;
  287. #endif // C++17
  288. #if __cplusplus >= 201103L
  289. _GLIBCXX_ABI_TAG_CXX11
  290. iterator
  291. erase(const_iterator __position)
  292. {
  293. __glibcxx_check_erase(__position);
  294. this->_M_invalidate_if(_Equal(__position.base()));
  295. return { _Base::erase(__position.base()), this };
  296. }
  297. #else
  298. void
  299. erase(iterator __position)
  300. {
  301. __glibcxx_check_erase(__position);
  302. this->_M_invalidate_if(_Equal(__position.base()));
  303. _Base::erase(__position.base());
  304. }
  305. #endif
  306. size_type
  307. erase(const key_type& __x)
  308. {
  309. _Base_iterator __victim = _Base::find(__x);
  310. if (__victim == _Base::end())
  311. return 0;
  312. else
  313. {
  314. this->_M_invalidate_if(_Equal(__victim));
  315. _Base::erase(__victim);
  316. return 1;
  317. }
  318. }
  319. #if __cplusplus >= 201103L
  320. _GLIBCXX_ABI_TAG_CXX11
  321. iterator
  322. erase(const_iterator __first, const_iterator __last)
  323. {
  324. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  325. // 151. can't currently clear() empty container
  326. __glibcxx_check_erase_range(__first, __last);
  327. for (_Base_const_iterator __victim = __first.base();
  328. __victim != __last.base(); ++__victim)
  329. {
  330. _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
  331. _M_message(__gnu_debug::__msg_valid_range)
  332. ._M_iterator(__first, "first")
  333. ._M_iterator(__last, "last"));
  334. this->_M_invalidate_if(_Equal(__victim));
  335. }
  336. return { _Base::erase(__first.base(), __last.base()), this };
  337. }
  338. #else
  339. void
  340. erase(iterator __first, iterator __last)
  341. {
  342. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  343. // 151. can't currently clear() empty container
  344. __glibcxx_check_erase_range(__first, __last);
  345. for (_Base_iterator __victim = __first.base();
  346. __victim != __last.base(); ++__victim)
  347. {
  348. _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
  349. _M_message(__gnu_debug::__msg_valid_range)
  350. ._M_iterator(__first, "first")
  351. ._M_iterator(__last, "last"));
  352. this->_M_invalidate_if(_Equal(__victim));
  353. }
  354. _Base::erase(__first.base(), __last.base());
  355. }
  356. #endif
  357. void
  358. swap(set& __x)
  359. _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
  360. {
  361. _Safe::_M_swap(__x);
  362. _Base::swap(__x);
  363. }
  364. void
  365. clear() _GLIBCXX_NOEXCEPT
  366. {
  367. this->_M_invalidate_all();
  368. _Base::clear();
  369. }
  370. // observers:
  371. using _Base::key_comp;
  372. using _Base::value_comp;
  373. // set operations:
  374. iterator
  375. find(const key_type& __x)
  376. { return iterator(_Base::find(__x), this); }
  377. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  378. // 214. set::find() missing const overload
  379. const_iterator
  380. find(const key_type& __x) const
  381. { return const_iterator(_Base::find(__x), this); }
  382. #if __cplusplus > 201103L
  383. template<typename _Kt,
  384. typename _Req =
  385. typename __has_is_transparent<_Compare, _Kt>::type>
  386. iterator
  387. find(const _Kt& __x)
  388. { return { _Base::find(__x), this }; }
  389. template<typename _Kt,
  390. typename _Req =
  391. typename __has_is_transparent<_Compare, _Kt>::type>
  392. const_iterator
  393. find(const _Kt& __x) const
  394. { return { _Base::find(__x), this }; }
  395. #endif
  396. using _Base::count;
  397. iterator
  398. lower_bound(const key_type& __x)
  399. { return iterator(_Base::lower_bound(__x), this); }
  400. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  401. // 214. set::find() missing const overload
  402. const_iterator
  403. lower_bound(const key_type& __x) const
  404. { return const_iterator(_Base::lower_bound(__x), this); }
  405. #if __cplusplus > 201103L
  406. template<typename _Kt,
  407. typename _Req =
  408. typename __has_is_transparent<_Compare, _Kt>::type>
  409. iterator
  410. lower_bound(const _Kt& __x)
  411. { return { _Base::lower_bound(__x), this }; }
  412. template<typename _Kt,
  413. typename _Req =
  414. typename __has_is_transparent<_Compare, _Kt>::type>
  415. const_iterator
  416. lower_bound(const _Kt& __x) const
  417. { return { _Base::lower_bound(__x), this }; }
  418. #endif
  419. iterator
  420. upper_bound(const key_type& __x)
  421. { return iterator(_Base::upper_bound(__x), this); }
  422. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  423. // 214. set::find() missing const overload
  424. const_iterator
  425. upper_bound(const key_type& __x) const
  426. { return const_iterator(_Base::upper_bound(__x), this); }
  427. #if __cplusplus > 201103L
  428. template<typename _Kt,
  429. typename _Req =
  430. typename __has_is_transparent<_Compare, _Kt>::type>
  431. iterator
  432. upper_bound(const _Kt& __x)
  433. { return { _Base::upper_bound(__x), this }; }
  434. template<typename _Kt,
  435. typename _Req =
  436. typename __has_is_transparent<_Compare, _Kt>::type>
  437. const_iterator
  438. upper_bound(const _Kt& __x) const
  439. { return { _Base::upper_bound(__x), this }; }
  440. #endif
  441. std::pair<iterator, iterator>
  442. equal_range(const key_type& __x)
  443. {
  444. std::pair<_Base_iterator, _Base_iterator> __res =
  445. _Base::equal_range(__x);
  446. return std::make_pair(iterator(__res.first, this),
  447. iterator(__res.second, this));
  448. }
  449. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  450. // 214. set::find() missing const overload
  451. std::pair<const_iterator, const_iterator>
  452. equal_range(const key_type& __x) const
  453. {
  454. std::pair<_Base_const_iterator, _Base_const_iterator> __res =
  455. _Base::equal_range(__x);
  456. return std::make_pair(const_iterator(__res.first, this),
  457. const_iterator(__res.second, this));
  458. }
  459. #if __cplusplus > 201103L
  460. template<typename _Kt,
  461. typename _Req =
  462. typename __has_is_transparent<_Compare, _Kt>::type>
  463. std::pair<iterator, iterator>
  464. equal_range(const _Kt& __x)
  465. {
  466. auto __res = _Base::equal_range(__x);
  467. return { { __res.first, this }, { __res.second, this } };
  468. }
  469. template<typename _Kt,
  470. typename _Req =
  471. typename __has_is_transparent<_Compare, _Kt>::type>
  472. std::pair<const_iterator, const_iterator>
  473. equal_range(const _Kt& __x) const
  474. {
  475. auto __res = _Base::equal_range(__x);
  476. return { { __res.first, this }, { __res.second, this } };
  477. }
  478. #endif
  479. _Base&
  480. _M_base() _GLIBCXX_NOEXCEPT { return *this; }
  481. const _Base&
  482. _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
  483. };
  484. #if __cpp_deduction_guides >= 201606
  485. template<typename _InputIterator,
  486. typename _Compare =
  487. less<typename iterator_traits<_InputIterator>::value_type>,
  488. typename _Allocator =
  489. allocator<typename iterator_traits<_InputIterator>::value_type>,
  490. typename = _RequireInputIter<_InputIterator>,
  491. typename = _RequireNotAllocator<_Compare>,
  492. typename = _RequireAllocator<_Allocator>>
  493. set(_InputIterator, _InputIterator,
  494. _Compare = _Compare(), _Allocator = _Allocator())
  495. -> set<typename iterator_traits<_InputIterator>::value_type,
  496. _Compare, _Allocator>;
  497. template<typename _Key, typename _Compare = less<_Key>,
  498. typename _Allocator = allocator<_Key>,
  499. typename = _RequireNotAllocator<_Compare>,
  500. typename = _RequireAllocator<_Allocator>>
  501. set(initializer_list<_Key>,
  502. _Compare = _Compare(), _Allocator = _Allocator())
  503. -> set<_Key, _Compare, _Allocator>;
  504. template<typename _InputIterator, typename _Allocator,
  505. typename = _RequireInputIter<_InputIterator>,
  506. typename = _RequireAllocator<_Allocator>>
  507. set(_InputIterator, _InputIterator, _Allocator)
  508. -> set<typename iterator_traits<_InputIterator>::value_type,
  509. less<typename iterator_traits<_InputIterator>::value_type>,
  510. _Allocator>;
  511. template<typename _Key, typename _Allocator,
  512. typename = _RequireAllocator<_Allocator>>
  513. set(initializer_list<_Key>, _Allocator)
  514. -> set<_Key, less<_Key>, _Allocator>;
  515. #endif // deduction guides
  516. template<typename _Key, typename _Compare, typename _Allocator>
  517. inline bool
  518. operator==(const set<_Key, _Compare, _Allocator>& __lhs,
  519. const set<_Key, _Compare, _Allocator>& __rhs)
  520. { return __lhs._M_base() == __rhs._M_base(); }
  521. #if __cpp_lib_three_way_comparison
  522. template<typename _Key, typename _Compare, typename _Alloc>
  523. inline __detail::__synth3way_t<_Key>
  524. operator<=>(const set<_Key, _Compare, _Alloc>& __lhs,
  525. const set<_Key, _Compare, _Alloc>& __rhs)
  526. { return __lhs._M_base() <=> __rhs._M_base(); }
  527. #else
  528. template<typename _Key, typename _Compare, typename _Allocator>
  529. inline bool
  530. operator!=(const set<_Key, _Compare, _Allocator>& __lhs,
  531. const set<_Key, _Compare, _Allocator>& __rhs)
  532. { return __lhs._M_base() != __rhs._M_base(); }
  533. template<typename _Key, typename _Compare, typename _Allocator>
  534. inline bool
  535. operator<(const set<_Key, _Compare, _Allocator>& __lhs,
  536. const set<_Key, _Compare, _Allocator>& __rhs)
  537. { return __lhs._M_base() < __rhs._M_base(); }
  538. template<typename _Key, typename _Compare, typename _Allocator>
  539. inline bool
  540. operator<=(const set<_Key, _Compare, _Allocator>& __lhs,
  541. const set<_Key, _Compare, _Allocator>& __rhs)
  542. { return __lhs._M_base() <= __rhs._M_base(); }
  543. template<typename _Key, typename _Compare, typename _Allocator>
  544. inline bool
  545. operator>=(const set<_Key, _Compare, _Allocator>& __lhs,
  546. const set<_Key, _Compare, _Allocator>& __rhs)
  547. { return __lhs._M_base() >= __rhs._M_base(); }
  548. template<typename _Key, typename _Compare, typename _Allocator>
  549. inline bool
  550. operator>(const set<_Key, _Compare, _Allocator>& __lhs,
  551. const set<_Key, _Compare, _Allocator>& __rhs)
  552. { return __lhs._M_base() > __rhs._M_base(); }
  553. #endif // three-way comparison
  554. template<typename _Key, typename _Compare, typename _Allocator>
  555. void
  556. swap(set<_Key, _Compare, _Allocator>& __x,
  557. set<_Key, _Compare, _Allocator>& __y)
  558. _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
  559. { return __x.swap(__y); }
  560. } // namespace __debug
  561. } // namespace std
  562. #endif