set.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. // Debugging set implementation -*- C++ -*-
  2. // Copyright (C) 2003-2022 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 <bits/stl_pair.h>
  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 __type_identity_t<allocator_type>& __a)
  95. : _Base(__x, __a) { }
  96. set(set&& __x, const __type_identity_t<allocator_type>& __a)
  97. noexcept( noexcept(_Base(std::move(__x), __a)) )
  98. : _Safe(std::move(__x), __a),
  99. _Base(std::move(__x), __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&) = default;
  126. set&
  127. operator=(set&&) = default;
  128. set&
  129. operator=(initializer_list<value_type> __l)
  130. {
  131. _Base::operator=(__l);
  132. this->_M_invalidate_all();
  133. return *this;
  134. }
  135. #endif
  136. using _Base::get_allocator;
  137. // iterators:
  138. iterator
  139. begin() _GLIBCXX_NOEXCEPT
  140. { return iterator(_Base::begin(), this); }
  141. const_iterator
  142. begin() const _GLIBCXX_NOEXCEPT
  143. { return const_iterator(_Base::begin(), this); }
  144. iterator
  145. end() _GLIBCXX_NOEXCEPT
  146. { return iterator(_Base::end(), this); }
  147. const_iterator
  148. end() const _GLIBCXX_NOEXCEPT
  149. { return const_iterator(_Base::end(), this); }
  150. reverse_iterator
  151. rbegin() _GLIBCXX_NOEXCEPT
  152. { return reverse_iterator(end()); }
  153. const_reverse_iterator
  154. rbegin() const _GLIBCXX_NOEXCEPT
  155. { return const_reverse_iterator(end()); }
  156. reverse_iterator
  157. rend() _GLIBCXX_NOEXCEPT
  158. { return reverse_iterator(begin()); }
  159. const_reverse_iterator
  160. rend() const _GLIBCXX_NOEXCEPT
  161. { return const_reverse_iterator(begin()); }
  162. #if __cplusplus >= 201103L
  163. const_iterator
  164. cbegin() const noexcept
  165. { return const_iterator(_Base::begin(), this); }
  166. const_iterator
  167. cend() const noexcept
  168. { return const_iterator(_Base::end(), this); }
  169. const_reverse_iterator
  170. crbegin() const noexcept
  171. { return const_reverse_iterator(end()); }
  172. const_reverse_iterator
  173. crend() const noexcept
  174. { return const_reverse_iterator(begin()); }
  175. #endif
  176. // capacity:
  177. using _Base::empty;
  178. using _Base::size;
  179. using _Base::max_size;
  180. // modifiers:
  181. #if __cplusplus >= 201103L
  182. template<typename... _Args>
  183. std::pair<iterator, bool>
  184. emplace(_Args&&... __args)
  185. {
  186. auto __res = _Base::emplace(std::forward<_Args>(__args)...);
  187. return { { __res.first, this }, __res.second };
  188. }
  189. template<typename... _Args>
  190. iterator
  191. emplace_hint(const_iterator __pos, _Args&&... __args)
  192. {
  193. __glibcxx_check_insert(__pos);
  194. return
  195. {
  196. _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...),
  197. this
  198. };
  199. }
  200. #endif
  201. std::pair<iterator, bool>
  202. insert(const value_type& __x)
  203. {
  204. std::pair<_Base_iterator, bool> __res = _Base::insert(__x);
  205. return std::pair<iterator, bool>(iterator(__res.first, this),
  206. __res.second);
  207. }
  208. #if __cplusplus >= 201103L
  209. std::pair<iterator, bool>
  210. insert(value_type&& __x)
  211. {
  212. auto __res = _Base::insert(std::move(__x));
  213. return { { __res.first, this }, __res.second };
  214. }
  215. #endif
  216. iterator
  217. insert(const_iterator __position, const value_type& __x)
  218. {
  219. __glibcxx_check_insert(__position);
  220. return iterator(_Base::insert(__position.base(), __x), this);
  221. }
  222. #if __cplusplus >= 201103L
  223. iterator
  224. insert(const_iterator __position, value_type&& __x)
  225. {
  226. __glibcxx_check_insert(__position);
  227. return { _Base::insert(__position.base(), std::move(__x)), this };
  228. }
  229. #endif
  230. template <typename _InputIterator>
  231. void
  232. insert(_InputIterator __first, _InputIterator __last)
  233. {
  234. typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
  235. __glibcxx_check_valid_range2(__first, __last, __dist);
  236. if (__dist.second >= __gnu_debug::__dp_sign)
  237. _Base::insert(__gnu_debug::__unsafe(__first),
  238. __gnu_debug::__unsafe(__last));
  239. else
  240. _Base::insert(__first, __last);
  241. }
  242. #if __cplusplus >= 201103L
  243. void
  244. insert(initializer_list<value_type> __l)
  245. { _Base::insert(__l); }
  246. #endif
  247. #if __cplusplus > 201402L
  248. using node_type = typename _Base::node_type;
  249. using insert_return_type = _Node_insert_return<iterator, node_type>;
  250. node_type
  251. extract(const_iterator __position)
  252. {
  253. __glibcxx_check_erase(__position);
  254. this->_M_invalidate_if(_Equal(__position.base()));
  255. return _Base::extract(__position.base());
  256. }
  257. node_type
  258. extract(const key_type& __key)
  259. {
  260. const auto __position = find(__key);
  261. if (__position != end())
  262. return extract(__position);
  263. return {};
  264. }
  265. insert_return_type
  266. insert(node_type&& __nh)
  267. {
  268. auto __ret = _Base::insert(std::move(__nh));
  269. iterator __pos = iterator(__ret.position, this);
  270. return { __pos, __ret.inserted, std::move(__ret.node) };
  271. }
  272. iterator
  273. insert(const_iterator __hint, node_type&& __nh)
  274. {
  275. __glibcxx_check_insert(__hint);
  276. return { _Base::insert(__hint.base(), std::move(__nh)), this };
  277. }
  278. using _Base::merge;
  279. #endif // C++17
  280. #if __cplusplus >= 201103L
  281. _GLIBCXX_ABI_TAG_CXX11
  282. iterator
  283. erase(const_iterator __position)
  284. {
  285. __glibcxx_check_erase(__position);
  286. return { erase(__position.base()), this };
  287. }
  288. _Base_iterator
  289. erase(_Base_const_iterator __position)
  290. {
  291. __glibcxx_check_erase2(__position);
  292. this->_M_invalidate_if(_Equal(__position));
  293. return _Base::erase(__position);
  294. }
  295. #else
  296. void
  297. erase(iterator __position)
  298. {
  299. __glibcxx_check_erase(__position);
  300. this->_M_invalidate_if(_Equal(__position.base()));
  301. _Base::erase(__position.base());
  302. }
  303. #endif
  304. size_type
  305. erase(const key_type& __x)
  306. {
  307. _Base_iterator __victim = _Base::find(__x);
  308. if (__victim == _Base::end())
  309. return 0;
  310. else
  311. {
  312. this->_M_invalidate_if(_Equal(__victim));
  313. _Base::erase(__victim);
  314. return 1;
  315. }
  316. }
  317. #if __cplusplus >= 201103L
  318. _GLIBCXX_ABI_TAG_CXX11
  319. iterator
  320. erase(const_iterator __first, const_iterator __last)
  321. {
  322. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  323. // 151. can't currently clear() empty container
  324. __glibcxx_check_erase_range(__first, __last);
  325. for (_Base_const_iterator __victim = __first.base();
  326. __victim != __last.base(); ++__victim)
  327. {
  328. _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
  329. _M_message(__gnu_debug::__msg_valid_range)
  330. ._M_iterator(__first, "first")
  331. ._M_iterator(__last, "last"));
  332. this->_M_invalidate_if(_Equal(__victim));
  333. }
  334. return { _Base::erase(__first.base(), __last.base()), this };
  335. }
  336. #else
  337. void
  338. erase(iterator __first, iterator __last)
  339. {
  340. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  341. // 151. can't currently clear() empty container
  342. __glibcxx_check_erase_range(__first, __last);
  343. for (_Base_iterator __victim = __first.base();
  344. __victim != __last.base(); ++__victim)
  345. {
  346. _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
  347. _M_message(__gnu_debug::__msg_valid_range)
  348. ._M_iterator(__first, "first")
  349. ._M_iterator(__last, "last"));
  350. this->_M_invalidate_if(_Equal(__victim));
  351. }
  352. _Base::erase(__first.base(), __last.base());
  353. }
  354. #endif
  355. void
  356. swap(set& __x)
  357. _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
  358. {
  359. _Safe::_M_swap(__x);
  360. _Base::swap(__x);
  361. }
  362. void
  363. clear() _GLIBCXX_NOEXCEPT
  364. {
  365. this->_M_invalidate_all();
  366. _Base::clear();
  367. }
  368. // observers:
  369. using _Base::key_comp;
  370. using _Base::value_comp;
  371. // set operations:
  372. iterator
  373. find(const key_type& __x)
  374. { return iterator(_Base::find(__x), this); }
  375. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  376. // 214. set::find() missing const overload
  377. const_iterator
  378. find(const key_type& __x) const
  379. { return const_iterator(_Base::find(__x), this); }
  380. #if __cplusplus > 201103L
  381. template<typename _Kt,
  382. typename _Req =
  383. typename __has_is_transparent<_Compare, _Kt>::type>
  384. iterator
  385. find(const _Kt& __x)
  386. { return { _Base::find(__x), this }; }
  387. template<typename _Kt,
  388. typename _Req =
  389. typename __has_is_transparent<_Compare, _Kt>::type>
  390. const_iterator
  391. find(const _Kt& __x) const
  392. { return { _Base::find(__x), this }; }
  393. #endif
  394. using _Base::count;
  395. iterator
  396. lower_bound(const key_type& __x)
  397. { return iterator(_Base::lower_bound(__x), this); }
  398. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  399. // 214. set::find() missing const overload
  400. const_iterator
  401. lower_bound(const key_type& __x) const
  402. { return const_iterator(_Base::lower_bound(__x), this); }
  403. #if __cplusplus > 201103L
  404. template<typename _Kt,
  405. typename _Req =
  406. typename __has_is_transparent<_Compare, _Kt>::type>
  407. iterator
  408. lower_bound(const _Kt& __x)
  409. { return { _Base::lower_bound(__x), this }; }
  410. template<typename _Kt,
  411. typename _Req =
  412. typename __has_is_transparent<_Compare, _Kt>::type>
  413. const_iterator
  414. lower_bound(const _Kt& __x) const
  415. { return { _Base::lower_bound(__x), this }; }
  416. #endif
  417. iterator
  418. upper_bound(const key_type& __x)
  419. { return iterator(_Base::upper_bound(__x), this); }
  420. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  421. // 214. set::find() missing const overload
  422. const_iterator
  423. upper_bound(const key_type& __x) const
  424. { return const_iterator(_Base::upper_bound(__x), this); }
  425. #if __cplusplus > 201103L
  426. template<typename _Kt,
  427. typename _Req =
  428. typename __has_is_transparent<_Compare, _Kt>::type>
  429. iterator
  430. upper_bound(const _Kt& __x)
  431. { return { _Base::upper_bound(__x), this }; }
  432. template<typename _Kt,
  433. typename _Req =
  434. typename __has_is_transparent<_Compare, _Kt>::type>
  435. const_iterator
  436. upper_bound(const _Kt& __x) const
  437. { return { _Base::upper_bound(__x), this }; }
  438. #endif
  439. std::pair<iterator, iterator>
  440. equal_range(const key_type& __x)
  441. {
  442. std::pair<_Base_iterator, _Base_iterator> __res =
  443. _Base::equal_range(__x);
  444. return std::make_pair(iterator(__res.first, this),
  445. iterator(__res.second, this));
  446. }
  447. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  448. // 214. set::find() missing const overload
  449. std::pair<const_iterator, const_iterator>
  450. equal_range(const key_type& __x) const
  451. {
  452. std::pair<_Base_const_iterator, _Base_const_iterator> __res =
  453. _Base::equal_range(__x);
  454. return std::make_pair(const_iterator(__res.first, this),
  455. const_iterator(__res.second, this));
  456. }
  457. #if __cplusplus > 201103L
  458. template<typename _Kt,
  459. typename _Req =
  460. typename __has_is_transparent<_Compare, _Kt>::type>
  461. std::pair<iterator, iterator>
  462. equal_range(const _Kt& __x)
  463. {
  464. auto __res = _Base::equal_range(__x);
  465. return { { __res.first, this }, { __res.second, this } };
  466. }
  467. template<typename _Kt,
  468. typename _Req =
  469. typename __has_is_transparent<_Compare, _Kt>::type>
  470. std::pair<const_iterator, const_iterator>
  471. equal_range(const _Kt& __x) const
  472. {
  473. auto __res = _Base::equal_range(__x);
  474. return { { __res.first, this }, { __res.second, this } };
  475. }
  476. #endif
  477. _Base&
  478. _M_base() _GLIBCXX_NOEXCEPT { return *this; }
  479. const _Base&
  480. _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
  481. };
  482. #if __cpp_deduction_guides >= 201606
  483. template<typename _InputIterator,
  484. typename _Compare =
  485. less<typename iterator_traits<_InputIterator>::value_type>,
  486. typename _Allocator =
  487. allocator<typename iterator_traits<_InputIterator>::value_type>,
  488. typename = _RequireInputIter<_InputIterator>,
  489. typename = _RequireNotAllocator<_Compare>,
  490. typename = _RequireAllocator<_Allocator>>
  491. set(_InputIterator, _InputIterator,
  492. _Compare = _Compare(), _Allocator = _Allocator())
  493. -> set<typename iterator_traits<_InputIterator>::value_type,
  494. _Compare, _Allocator>;
  495. template<typename _Key, typename _Compare = less<_Key>,
  496. typename _Allocator = allocator<_Key>,
  497. typename = _RequireNotAllocator<_Compare>,
  498. typename = _RequireAllocator<_Allocator>>
  499. set(initializer_list<_Key>,
  500. _Compare = _Compare(), _Allocator = _Allocator())
  501. -> set<_Key, _Compare, _Allocator>;
  502. template<typename _InputIterator, typename _Allocator,
  503. typename = _RequireInputIter<_InputIterator>,
  504. typename = _RequireAllocator<_Allocator>>
  505. set(_InputIterator, _InputIterator, _Allocator)
  506. -> set<typename iterator_traits<_InputIterator>::value_type,
  507. less<typename iterator_traits<_InputIterator>::value_type>,
  508. _Allocator>;
  509. template<typename _Key, typename _Allocator,
  510. typename = _RequireAllocator<_Allocator>>
  511. set(initializer_list<_Key>, _Allocator)
  512. -> set<_Key, less<_Key>, _Allocator>;
  513. #endif // deduction guides
  514. template<typename _Key, typename _Compare, typename _Allocator>
  515. inline bool
  516. operator==(const set<_Key, _Compare, _Allocator>& __lhs,
  517. const set<_Key, _Compare, _Allocator>& __rhs)
  518. { return __lhs._M_base() == __rhs._M_base(); }
  519. #if __cpp_lib_three_way_comparison
  520. template<typename _Key, typename _Compare, typename _Alloc>
  521. inline __detail::__synth3way_t<_Key>
  522. operator<=>(const set<_Key, _Compare, _Alloc>& __lhs,
  523. const set<_Key, _Compare, _Alloc>& __rhs)
  524. { return __lhs._M_base() <=> __rhs._M_base(); }
  525. #else
  526. template<typename _Key, typename _Compare, typename _Allocator>
  527. inline bool
  528. operator!=(const set<_Key, _Compare, _Allocator>& __lhs,
  529. const set<_Key, _Compare, _Allocator>& __rhs)
  530. { return __lhs._M_base() != __rhs._M_base(); }
  531. template<typename _Key, typename _Compare, typename _Allocator>
  532. inline bool
  533. operator<(const set<_Key, _Compare, _Allocator>& __lhs,
  534. const set<_Key, _Compare, _Allocator>& __rhs)
  535. { return __lhs._M_base() < __rhs._M_base(); }
  536. template<typename _Key, typename _Compare, typename _Allocator>
  537. inline bool
  538. operator<=(const set<_Key, _Compare, _Allocator>& __lhs,
  539. const set<_Key, _Compare, _Allocator>& __rhs)
  540. { return __lhs._M_base() <= __rhs._M_base(); }
  541. template<typename _Key, typename _Compare, typename _Allocator>
  542. inline bool
  543. operator>=(const set<_Key, _Compare, _Allocator>& __lhs,
  544. const set<_Key, _Compare, _Allocator>& __rhs)
  545. { return __lhs._M_base() >= __rhs._M_base(); }
  546. template<typename _Key, typename _Compare, typename _Allocator>
  547. inline bool
  548. operator>(const set<_Key, _Compare, _Allocator>& __lhs,
  549. const set<_Key, _Compare, _Allocator>& __rhs)
  550. { return __lhs._M_base() > __rhs._M_base(); }
  551. #endif // three-way comparison
  552. template<typename _Key, typename _Compare, typename _Allocator>
  553. void
  554. swap(set<_Key, _Compare, _Allocator>& __x,
  555. set<_Key, _Compare, _Allocator>& __y)
  556. _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
  557. { return __x.swap(__y); }
  558. } // namespace __debug
  559. } // namespace std
  560. #endif