unordered_set 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  1. // Debugging unordered_set/unordered_multiset 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/unordered_set
  21. * This file is a GNU debug extension to the Standard C++ Library.
  22. */
  23. #ifndef _GLIBCXX_DEBUG_UNORDERED_SET
  24. #define _GLIBCXX_DEBUG_UNORDERED_SET 1
  25. #pragma GCC system_header
  26. #if __cplusplus < 201103L
  27. # include <bits/c++0x_warning.h>
  28. #else
  29. # include <bits/c++config.h>
  30. namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug {
  31. template<typename _Key, typename _Hash, typename _Pred, typename _Allocator>
  32. class unordered_set;
  33. template<typename _Key, typename _Hash, typename _Pred, typename _Allocator>
  34. class unordered_multiset;
  35. } } // namespace std::__debug
  36. # include <unordered_set>
  37. #include <debug/safe_unordered_container.h>
  38. #include <debug/safe_container.h>
  39. #include <debug/safe_iterator.h>
  40. #include <debug/safe_local_iterator.h>
  41. namespace std _GLIBCXX_VISIBILITY(default)
  42. {
  43. namespace __debug
  44. {
  45. /// Class std::unordered_set with safety/checking/debug instrumentation.
  46. template<typename _Value,
  47. typename _Hash = std::hash<_Value>,
  48. typename _Pred = std::equal_to<_Value>,
  49. typename _Alloc = std::allocator<_Value> >
  50. class unordered_set
  51. : public __gnu_debug::_Safe_container<
  52. unordered_set<_Value, _Hash, _Pred, _Alloc>, _Alloc,
  53. __gnu_debug::_Safe_unordered_container>,
  54. public _GLIBCXX_STD_C::unordered_set<_Value, _Hash, _Pred, _Alloc>
  55. {
  56. typedef _GLIBCXX_STD_C::unordered_set<
  57. _Value, _Hash, _Pred, _Alloc> _Base;
  58. typedef __gnu_debug::_Safe_container<
  59. unordered_set, _Alloc, __gnu_debug::_Safe_unordered_container> _Safe;
  60. typedef typename _Base::const_iterator _Base_const_iterator;
  61. typedef typename _Base::iterator _Base_iterator;
  62. typedef typename _Base::const_local_iterator _Base_const_local_iterator;
  63. typedef typename _Base::local_iterator _Base_local_iterator;
  64. template<typename _ItT, typename _SeqT, typename _CatT>
  65. friend class ::__gnu_debug::_Safe_iterator;
  66. template<typename _ItT, typename _SeqT>
  67. friend class ::__gnu_debug::_Safe_local_iterator;
  68. // Reference wrapper for base class. See PR libstdc++/90102.
  69. struct _Base_ref
  70. {
  71. _Base_ref(const _Base& __r) : _M_ref(__r) { }
  72. const _Base& _M_ref;
  73. };
  74. public:
  75. typedef typename _Base::size_type size_type;
  76. typedef typename _Base::hasher hasher;
  77. typedef typename _Base::key_equal key_equal;
  78. typedef typename _Base::allocator_type allocator_type;
  79. typedef typename _Base::key_type key_type;
  80. typedef typename _Base::value_type value_type;
  81. typedef __gnu_debug::_Safe_iterator<
  82. _Base_iterator, unordered_set> iterator;
  83. typedef __gnu_debug::_Safe_iterator<
  84. _Base_const_iterator, unordered_set> const_iterator;
  85. typedef __gnu_debug::_Safe_local_iterator<
  86. _Base_local_iterator, unordered_set> local_iterator;
  87. typedef __gnu_debug::_Safe_local_iterator<
  88. _Base_const_local_iterator, unordered_set> const_local_iterator;
  89. unordered_set() = default;
  90. explicit
  91. unordered_set(size_type __n,
  92. const hasher& __hf = hasher(),
  93. const key_equal& __eql = key_equal(),
  94. const allocator_type& __a = allocator_type())
  95. : _Base(__n, __hf, __eql, __a) { }
  96. template<typename _InputIterator>
  97. unordered_set(_InputIterator __first, _InputIterator __last,
  98. size_type __n = 0,
  99. const hasher& __hf = hasher(),
  100. const key_equal& __eql = key_equal(),
  101. const allocator_type& __a = allocator_type())
  102. : _Base(__gnu_debug::__base(
  103. __glibcxx_check_valid_constructor_range(__first, __last)),
  104. __gnu_debug::__base(__last), __n,
  105. __hf, __eql, __a) { }
  106. unordered_set(const unordered_set&) = default;
  107. unordered_set(_Base_ref __x)
  108. : _Base(__x._M_ref) { }
  109. unordered_set(unordered_set&&) = default;
  110. explicit
  111. unordered_set(const allocator_type& __a)
  112. : _Base(__a) { }
  113. unordered_set(const unordered_set& __uset,
  114. const allocator_type& __a)
  115. : _Base(__uset, __a) { }
  116. unordered_set(unordered_set&& __uset,
  117. const allocator_type& __a)
  118. noexcept( noexcept(_Base(std::move(__uset._M_base()), __a)) )
  119. : _Safe(std::move(__uset._M_safe()), __a),
  120. _Base(std::move(__uset._M_base()), __a) { }
  121. unordered_set(initializer_list<value_type> __l,
  122. size_type __n = 0,
  123. const hasher& __hf = hasher(),
  124. const key_equal& __eql = key_equal(),
  125. const allocator_type& __a = allocator_type())
  126. : _Base(__l, __n, __hf, __eql, __a) { }
  127. unordered_set(size_type __n, const allocator_type& __a)
  128. : unordered_set(__n, hasher(), key_equal(), __a)
  129. { }
  130. unordered_set(size_type __n, const hasher& __hf,
  131. const allocator_type& __a)
  132. : unordered_set(__n, __hf, key_equal(), __a)
  133. { }
  134. template<typename _InputIterator>
  135. unordered_set(_InputIterator __first, _InputIterator __last,
  136. size_type __n,
  137. const allocator_type& __a)
  138. : unordered_set(__first, __last, __n, hasher(), key_equal(), __a)
  139. { }
  140. template<typename _InputIterator>
  141. unordered_set(_InputIterator __first, _InputIterator __last,
  142. size_type __n, const hasher& __hf,
  143. const allocator_type& __a)
  144. : unordered_set(__first, __last, __n, __hf, key_equal(), __a)
  145. { }
  146. unordered_set(initializer_list<value_type> __l,
  147. size_type __n,
  148. const allocator_type& __a)
  149. : unordered_set(__l, __n, hasher(), key_equal(), __a)
  150. { }
  151. unordered_set(initializer_list<value_type> __l,
  152. size_type __n, const hasher& __hf,
  153. const allocator_type& __a)
  154. : unordered_set(__l, __n, __hf, key_equal(), __a)
  155. { }
  156. ~unordered_set() = default;
  157. unordered_set&
  158. operator=(const unordered_set&) = default;
  159. unordered_set&
  160. operator=(unordered_set&&) = default;
  161. unordered_set&
  162. operator=(initializer_list<value_type> __l)
  163. {
  164. _M_base() = __l;
  165. this->_M_invalidate_all();
  166. return *this;
  167. }
  168. void
  169. swap(unordered_set& __x)
  170. noexcept( noexcept(declval<_Base&>().swap(__x)) )
  171. {
  172. _Safe::_M_swap(__x);
  173. _Base::swap(__x);
  174. }
  175. void
  176. clear() noexcept
  177. {
  178. _Base::clear();
  179. this->_M_invalidate_all();
  180. }
  181. iterator
  182. begin() noexcept
  183. { return { _Base::begin(), this }; }
  184. const_iterator
  185. begin() const noexcept
  186. { return { _Base::begin(), this }; }
  187. iterator
  188. end() noexcept
  189. { return { _Base::end(), this }; }
  190. const_iterator
  191. end() const noexcept
  192. { return { _Base::end(), this }; }
  193. const_iterator
  194. cbegin() const noexcept
  195. { return { _Base::cbegin(), this }; }
  196. const_iterator
  197. cend() const noexcept
  198. { return { _Base::cend(), this }; }
  199. // local versions
  200. local_iterator
  201. begin(size_type __b)
  202. {
  203. __glibcxx_check_bucket_index(__b);
  204. return { _Base::begin(__b), this };
  205. }
  206. local_iterator
  207. end(size_type __b)
  208. {
  209. __glibcxx_check_bucket_index(__b);
  210. return { _Base::end(__b), this };
  211. }
  212. const_local_iterator
  213. begin(size_type __b) const
  214. {
  215. __glibcxx_check_bucket_index(__b);
  216. return { _Base::begin(__b), this };
  217. }
  218. const_local_iterator
  219. end(size_type __b) const
  220. {
  221. __glibcxx_check_bucket_index(__b);
  222. return { _Base::end(__b), this };
  223. }
  224. const_local_iterator
  225. cbegin(size_type __b) const
  226. {
  227. __glibcxx_check_bucket_index(__b);
  228. return { _Base::cbegin(__b), this };
  229. }
  230. const_local_iterator
  231. cend(size_type __b) const
  232. {
  233. __glibcxx_check_bucket_index(__b);
  234. return { _Base::cend(__b), this };
  235. }
  236. size_type
  237. bucket_size(size_type __b) const
  238. {
  239. __glibcxx_check_bucket_index(__b);
  240. return _Base::bucket_size(__b);
  241. }
  242. float
  243. max_load_factor() const noexcept
  244. { return _Base::max_load_factor(); }
  245. void
  246. max_load_factor(float __f)
  247. {
  248. __glibcxx_check_max_load_factor(__f);
  249. _Base::max_load_factor(__f);
  250. }
  251. template<typename... _Args>
  252. std::pair<iterator, bool>
  253. emplace(_Args&&... __args)
  254. {
  255. size_type __bucket_count = this->bucket_count();
  256. auto __res = _Base::emplace(std::forward<_Args>(__args)...);
  257. _M_check_rehashed(__bucket_count);
  258. return { { __res.first, this }, __res.second };
  259. }
  260. template<typename... _Args>
  261. iterator
  262. emplace_hint(const_iterator __hint, _Args&&... __args)
  263. {
  264. __glibcxx_check_insert(__hint);
  265. size_type __bucket_count = this->bucket_count();
  266. auto __it = _Base::emplace_hint(__hint.base(),
  267. std::forward<_Args>(__args)...);
  268. _M_check_rehashed(__bucket_count);
  269. return { __it, this };
  270. }
  271. std::pair<iterator, bool>
  272. insert(const value_type& __obj)
  273. {
  274. size_type __bucket_count = this->bucket_count();
  275. auto __res = _Base::insert(__obj);
  276. _M_check_rehashed(__bucket_count);
  277. return { { __res.first, this }, __res.second };
  278. }
  279. iterator
  280. insert(const_iterator __hint, const value_type& __obj)
  281. {
  282. __glibcxx_check_insert(__hint);
  283. size_type __bucket_count = this->bucket_count();
  284. auto __it = _Base::insert(__hint.base(), __obj);
  285. _M_check_rehashed(__bucket_count);
  286. return { __it, this };
  287. }
  288. std::pair<iterator, bool>
  289. insert(value_type&& __obj)
  290. {
  291. size_type __bucket_count = this->bucket_count();
  292. auto __res = _Base::insert(std::move(__obj));
  293. _M_check_rehashed(__bucket_count);
  294. return { { __res.first, this }, __res.second };
  295. }
  296. iterator
  297. insert(const_iterator __hint, value_type&& __obj)
  298. {
  299. __glibcxx_check_insert(__hint);
  300. size_type __bucket_count = this->bucket_count();
  301. auto __it = _Base::insert(__hint.base(), std::move(__obj));
  302. _M_check_rehashed(__bucket_count);
  303. return { __it, this };
  304. }
  305. void
  306. insert(std::initializer_list<value_type> __l)
  307. {
  308. size_type __bucket_count = this->bucket_count();
  309. _Base::insert(__l);
  310. _M_check_rehashed(__bucket_count);
  311. }
  312. template<typename _InputIterator>
  313. void
  314. insert(_InputIterator __first, _InputIterator __last)
  315. {
  316. typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
  317. __glibcxx_check_valid_range2(__first, __last, __dist);
  318. size_type __bucket_count = this->bucket_count();
  319. if (__dist.second >= __gnu_debug::__dp_sign)
  320. _Base::insert(__gnu_debug::__unsafe(__first),
  321. __gnu_debug::__unsafe(__last));
  322. else
  323. _Base::insert(__first, __last);
  324. _M_check_rehashed(__bucket_count);
  325. }
  326. #if __cplusplus > 201402L
  327. using node_type = typename _Base::node_type;
  328. using insert_return_type = _Node_insert_return<iterator, node_type>;
  329. node_type
  330. extract(const_iterator __position)
  331. {
  332. __glibcxx_check_erase(__position);
  333. return _M_extract(__position.base());
  334. }
  335. node_type
  336. extract(const key_type& __key)
  337. {
  338. const auto __position = _Base::find(__key);
  339. if (__position != _Base::end())
  340. return _M_extract(__position);
  341. return {};
  342. }
  343. insert_return_type
  344. insert(node_type&& __nh)
  345. {
  346. auto __ret = _Base::insert(std::move(__nh));
  347. return
  348. { { __ret.position, this }, __ret.inserted, std::move(__ret.node) };
  349. }
  350. iterator
  351. insert(const_iterator __hint, node_type&& __nh)
  352. {
  353. __glibcxx_check_insert(__hint);
  354. return { _Base::insert(__hint.base(), std::move(__nh)), this };
  355. }
  356. using _Base::merge;
  357. #endif // C++17
  358. iterator
  359. find(const key_type& __key)
  360. { return { _Base::find(__key), this }; }
  361. #if __cplusplus > 201703L
  362. template<typename _Kt,
  363. typename = std::__has_is_transparent_t<_Hash, _Kt>,
  364. typename = std::__has_is_transparent_t<_Pred, _Kt>>
  365. iterator
  366. find(const _Kt& __k)
  367. { return { _Base::find(__k), this }; }
  368. #endif
  369. const_iterator
  370. find(const key_type& __key) const
  371. { return { _Base::find(__key), this }; }
  372. #if __cplusplus > 201703L
  373. template<typename _Kt,
  374. typename = std::__has_is_transparent_t<_Hash, _Kt>,
  375. typename = std::__has_is_transparent_t<_Pred, _Kt>>
  376. const_iterator
  377. find(const _Kt& __k) const
  378. { return { _Base::find(__k), this }; }
  379. #endif
  380. std::pair<iterator, iterator>
  381. equal_range(const key_type& __key)
  382. {
  383. auto __res = _Base::equal_range(__key);
  384. return { { __res.first, this }, { __res.second, this } };
  385. }
  386. #if __cplusplus > 201703L
  387. template<typename _Kt,
  388. typename = std::__has_is_transparent_t<_Hash, _Kt>,
  389. typename = std::__has_is_transparent_t<_Pred, _Kt>>
  390. std::pair<iterator, iterator>
  391. equal_range(const _Kt& __k)
  392. {
  393. auto __res = _Base::equal_range(__k);
  394. return { { __res.first, this }, { __res.second, this } };
  395. }
  396. #endif
  397. std::pair<const_iterator, const_iterator>
  398. equal_range(const key_type& __key) const
  399. {
  400. auto __res = _Base::equal_range(__key);
  401. return { { __res.first, this }, { __res.second, this } };
  402. }
  403. #if __cplusplus > 201703L
  404. template<typename _Kt,
  405. typename = std::__has_is_transparent_t<_Hash, _Kt>,
  406. typename = std::__has_is_transparent_t<_Pred, _Kt>>
  407. std::pair<const_iterator, const_iterator>
  408. equal_range(const _Kt& __k) const
  409. {
  410. auto __res = _Base::equal_range(__k);
  411. return { { __res.first, this }, { __res.second, this } };
  412. }
  413. #endif
  414. size_type
  415. erase(const key_type& __key)
  416. {
  417. size_type __ret(0);
  418. auto __victim = _Base::find(__key);
  419. if (__victim != _Base::end())
  420. {
  421. _M_erase(__victim);
  422. __ret = 1;
  423. }
  424. return __ret;
  425. }
  426. iterator
  427. erase(const_iterator __it)
  428. {
  429. __glibcxx_check_erase(__it);
  430. return { _M_erase(__it.base()), this };
  431. }
  432. iterator
  433. erase(iterator __it)
  434. {
  435. __glibcxx_check_erase(__it);
  436. return { _M_erase(__it.base()), this };
  437. }
  438. iterator
  439. erase(const_iterator __first, const_iterator __last)
  440. {
  441. __glibcxx_check_erase_range(__first, __last);
  442. for (auto __tmp = __first.base(); __tmp != __last.base(); ++__tmp)
  443. {
  444. _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(),
  445. _M_message(__gnu_debug::__msg_valid_range)
  446. ._M_iterator(__first, "first")
  447. ._M_iterator(__last, "last"));
  448. _M_invalidate(__tmp);
  449. }
  450. size_type __bucket_count = this->bucket_count();
  451. auto __next = _Base::erase(__first.base(), __last.base());
  452. _M_check_rehashed(__bucket_count);
  453. return { __next, this };
  454. }
  455. _Base&
  456. _M_base() noexcept { return *this; }
  457. const _Base&
  458. _M_base() const noexcept { return *this; }
  459. private:
  460. void
  461. _M_check_rehashed(size_type __prev_count)
  462. {
  463. if (__prev_count != this->bucket_count())
  464. this->_M_invalidate_all();
  465. }
  466. void
  467. _M_invalidate(_Base_const_iterator __victim)
  468. {
  469. this->_M_invalidate_if(
  470. [__victim](_Base_const_iterator __it) { return __it == __victim; });
  471. this->_M_invalidate_local_if(
  472. [__victim](_Base_const_local_iterator __it)
  473. { return __it == __victim; });
  474. }
  475. _Base_iterator
  476. _M_erase(_Base_const_iterator __victim)
  477. {
  478. _M_invalidate(__victim);
  479. size_type __bucket_count = this->bucket_count();
  480. _Base_iterator __next = _Base::erase(__victim);
  481. _M_check_rehashed(__bucket_count);
  482. return __next;
  483. }
  484. #if __cplusplus > 201402L
  485. node_type
  486. _M_extract(_Base_const_iterator __victim)
  487. {
  488. _M_invalidate(__victim);
  489. return _Base::extract(__victim);
  490. }
  491. #endif
  492. };
  493. #if __cpp_deduction_guides >= 201606
  494. template<typename _InputIterator,
  495. typename _Hash =
  496. hash<typename iterator_traits<_InputIterator>::value_type>,
  497. typename _Pred =
  498. equal_to<typename iterator_traits<_InputIterator>::value_type>,
  499. typename _Allocator =
  500. allocator<typename iterator_traits<_InputIterator>::value_type>,
  501. typename = _RequireInputIter<_InputIterator>,
  502. typename = _RequireNotAllocatorOrIntegral<_Hash>,
  503. typename = _RequireNotAllocator<_Pred>,
  504. typename = _RequireAllocator<_Allocator>>
  505. unordered_set(_InputIterator, _InputIterator,
  506. unordered_set<int>::size_type = {},
  507. _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
  508. -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
  509. _Hash, _Pred, _Allocator>;
  510. template<typename _Tp, typename _Hash = hash<_Tp>,
  511. typename _Pred = equal_to<_Tp>,
  512. typename _Allocator = allocator<_Tp>,
  513. typename = _RequireNotAllocatorOrIntegral<_Hash>,
  514. typename = _RequireNotAllocator<_Pred>,
  515. typename = _RequireAllocator<_Allocator>>
  516. unordered_set(initializer_list<_Tp>,
  517. unordered_set<int>::size_type = {},
  518. _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
  519. -> unordered_set<_Tp, _Hash, _Pred, _Allocator>;
  520. template<typename _InputIterator, typename _Allocator,
  521. typename = _RequireInputIter<_InputIterator>,
  522. typename = _RequireAllocator<_Allocator>>
  523. unordered_set(_InputIterator, _InputIterator,
  524. unordered_set<int>::size_type, _Allocator)
  525. -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
  526. hash<
  527. typename iterator_traits<_InputIterator>::value_type>,
  528. equal_to<
  529. typename iterator_traits<_InputIterator>::value_type>,
  530. _Allocator>;
  531. template<typename _InputIterator, typename _Hash, typename _Allocator,
  532. typename = _RequireInputIter<_InputIterator>,
  533. typename = _RequireNotAllocatorOrIntegral<_Hash>,
  534. typename = _RequireAllocator<_Allocator>>
  535. unordered_set(_InputIterator, _InputIterator,
  536. unordered_set<int>::size_type,
  537. _Hash, _Allocator)
  538. -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
  539. _Hash,
  540. equal_to<
  541. typename iterator_traits<_InputIterator>::value_type>,
  542. _Allocator>;
  543. template<typename _Tp, typename _Allocator,
  544. typename = _RequireAllocator<_Allocator>>
  545. unordered_set(initializer_list<_Tp>,
  546. unordered_set<int>::size_type, _Allocator)
  547. -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
  548. template<typename _Tp, typename _Hash, typename _Allocator,
  549. typename = _RequireNotAllocatorOrIntegral<_Hash>,
  550. typename = _RequireAllocator<_Allocator>>
  551. unordered_set(initializer_list<_Tp>,
  552. unordered_set<int>::size_type, _Hash, _Allocator)
  553. -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
  554. #endif
  555. template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
  556. inline void
  557. swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
  558. unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
  559. noexcept(noexcept(__x.swap(__y)))
  560. { __x.swap(__y); }
  561. template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
  562. inline bool
  563. operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
  564. const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
  565. { return __x._M_base() == __y._M_base(); }
  566. #if __cpp_impl_three_way_comparison < 201907L
  567. template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
  568. inline bool
  569. operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
  570. const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
  571. { return !(__x == __y); }
  572. #endif
  573. /// Class std::unordered_multiset with safety/checking/debug instrumentation.
  574. template<typename _Value,
  575. typename _Hash = std::hash<_Value>,
  576. typename _Pred = std::equal_to<_Value>,
  577. typename _Alloc = std::allocator<_Value> >
  578. class unordered_multiset
  579. : public __gnu_debug::_Safe_container<
  580. unordered_multiset<_Value, _Hash, _Pred, _Alloc>, _Alloc,
  581. __gnu_debug::_Safe_unordered_container>,
  582. public _GLIBCXX_STD_C::unordered_multiset<_Value, _Hash, _Pred, _Alloc>
  583. {
  584. typedef _GLIBCXX_STD_C::unordered_multiset<
  585. _Value, _Hash, _Pred, _Alloc> _Base;
  586. typedef __gnu_debug::_Safe_container<unordered_multiset,
  587. _Alloc, __gnu_debug::_Safe_unordered_container> _Safe;
  588. typedef typename _Base::const_iterator _Base_const_iterator;
  589. typedef typename _Base::iterator _Base_iterator;
  590. typedef typename _Base::const_local_iterator
  591. _Base_const_local_iterator;
  592. typedef typename _Base::local_iterator _Base_local_iterator;
  593. template<typename _ItT, typename _SeqT, typename _CatT>
  594. friend class ::__gnu_debug::_Safe_iterator;
  595. template<typename _ItT, typename _SeqT>
  596. friend class ::__gnu_debug::_Safe_local_iterator;
  597. // Reference wrapper for base class. See PR libstdc++/90102.
  598. struct _Base_ref
  599. {
  600. _Base_ref(const _Base& __r) : _M_ref(__r) { }
  601. const _Base& _M_ref;
  602. };
  603. public:
  604. typedef typename _Base::size_type size_type;
  605. typedef typename _Base::hasher hasher;
  606. typedef typename _Base::key_equal key_equal;
  607. typedef typename _Base::allocator_type allocator_type;
  608. typedef typename _Base::key_type key_type;
  609. typedef typename _Base::value_type value_type;
  610. typedef __gnu_debug::_Safe_iterator<
  611. _Base_iterator, unordered_multiset> iterator;
  612. typedef __gnu_debug::_Safe_iterator<
  613. _Base_const_iterator, unordered_multiset> const_iterator;
  614. typedef __gnu_debug::_Safe_local_iterator<
  615. _Base_local_iterator, unordered_multiset> local_iterator;
  616. typedef __gnu_debug::_Safe_local_iterator<
  617. _Base_const_local_iterator, unordered_multiset> const_local_iterator;
  618. unordered_multiset() = default;
  619. explicit
  620. unordered_multiset(size_type __n,
  621. const hasher& __hf = hasher(),
  622. const key_equal& __eql = key_equal(),
  623. const allocator_type& __a = allocator_type())
  624. : _Base(__n, __hf, __eql, __a) { }
  625. template<typename _InputIterator>
  626. unordered_multiset(_InputIterator __first, _InputIterator __last,
  627. size_type __n = 0,
  628. const hasher& __hf = hasher(),
  629. const key_equal& __eql = key_equal(),
  630. const allocator_type& __a = allocator_type())
  631. : _Base(__gnu_debug::__base(
  632. __glibcxx_check_valid_constructor_range(__first, __last)),
  633. __gnu_debug::__base(__last), __n,
  634. __hf, __eql, __a) { }
  635. unordered_multiset(const unordered_multiset&) = default;
  636. unordered_multiset(_Base_ref __x)
  637. : _Base(__x._M_ref) { }
  638. unordered_multiset(unordered_multiset&&) = default;
  639. explicit
  640. unordered_multiset(const allocator_type& __a)
  641. : _Base(__a) { }
  642. unordered_multiset(const unordered_multiset& __uset,
  643. const allocator_type& __a)
  644. : _Base(__uset, __a) { }
  645. unordered_multiset(unordered_multiset&& __uset,
  646. const allocator_type& __a)
  647. noexcept( noexcept(_Base(std::move(__uset._M_base()), __a)) )
  648. : _Safe(std::move(__uset._M_safe()), __a),
  649. _Base(std::move(__uset._M_base()), __a) { }
  650. unordered_multiset(initializer_list<value_type> __l,
  651. size_type __n = 0,
  652. const hasher& __hf = hasher(),
  653. const key_equal& __eql = key_equal(),
  654. const allocator_type& __a = allocator_type())
  655. : _Base(__l, __n, __hf, __eql, __a) { }
  656. unordered_multiset(size_type __n, const allocator_type& __a)
  657. : unordered_multiset(__n, hasher(), key_equal(), __a)
  658. { }
  659. unordered_multiset(size_type __n, const hasher& __hf,
  660. const allocator_type& __a)
  661. : unordered_multiset(__n, __hf, key_equal(), __a)
  662. { }
  663. template<typename _InputIterator>
  664. unordered_multiset(_InputIterator __first, _InputIterator __last,
  665. size_type __n,
  666. const allocator_type& __a)
  667. : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a)
  668. { }
  669. template<typename _InputIterator>
  670. unordered_multiset(_InputIterator __first, _InputIterator __last,
  671. size_type __n, const hasher& __hf,
  672. const allocator_type& __a)
  673. : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a)
  674. { }
  675. unordered_multiset(initializer_list<value_type> __l,
  676. size_type __n,
  677. const allocator_type& __a)
  678. : unordered_multiset(__l, __n, hasher(), key_equal(), __a)
  679. { }
  680. unordered_multiset(initializer_list<value_type> __l,
  681. size_type __n, const hasher& __hf,
  682. const allocator_type& __a)
  683. : unordered_multiset(__l, __n, __hf, key_equal(), __a)
  684. { }
  685. ~unordered_multiset() = default;
  686. unordered_multiset&
  687. operator=(const unordered_multiset&) = default;
  688. unordered_multiset&
  689. operator=(unordered_multiset&&) = default;
  690. unordered_multiset&
  691. operator=(initializer_list<value_type> __l)
  692. {
  693. this->_M_base() = __l;
  694. this->_M_invalidate_all();
  695. return *this;
  696. }
  697. void
  698. swap(unordered_multiset& __x)
  699. noexcept( noexcept(declval<_Base&>().swap(__x)) )
  700. {
  701. _Safe::_M_swap(__x);
  702. _Base::swap(__x);
  703. }
  704. void
  705. clear() noexcept
  706. {
  707. _Base::clear();
  708. this->_M_invalidate_all();
  709. }
  710. iterator
  711. begin() noexcept
  712. { return { _Base::begin(), this }; }
  713. const_iterator
  714. begin() const noexcept
  715. { return { _Base::begin(), this }; }
  716. iterator
  717. end() noexcept
  718. { return { _Base::end(), this }; }
  719. const_iterator
  720. end() const noexcept
  721. { return { _Base::end(), this }; }
  722. const_iterator
  723. cbegin() const noexcept
  724. { return { _Base::cbegin(), this }; }
  725. const_iterator
  726. cend() const noexcept
  727. { return { _Base::cend(), this }; }
  728. // local versions
  729. local_iterator
  730. begin(size_type __b)
  731. {
  732. __glibcxx_check_bucket_index(__b);
  733. return { _Base::begin(__b), this };
  734. }
  735. local_iterator
  736. end(size_type __b)
  737. {
  738. __glibcxx_check_bucket_index(__b);
  739. return { _Base::end(__b), this };
  740. }
  741. const_local_iterator
  742. begin(size_type __b) const
  743. {
  744. __glibcxx_check_bucket_index(__b);
  745. return { _Base::begin(__b), this };
  746. }
  747. const_local_iterator
  748. end(size_type __b) const
  749. {
  750. __glibcxx_check_bucket_index(__b);
  751. return { _Base::end(__b), this };
  752. }
  753. const_local_iterator
  754. cbegin(size_type __b) const
  755. {
  756. __glibcxx_check_bucket_index(__b);
  757. return { _Base::cbegin(__b), this };
  758. }
  759. const_local_iterator
  760. cend(size_type __b) const
  761. {
  762. __glibcxx_check_bucket_index(__b);
  763. return { _Base::cend(__b), this };
  764. }
  765. size_type
  766. bucket_size(size_type __b) const
  767. {
  768. __glibcxx_check_bucket_index(__b);
  769. return _Base::bucket_size(__b);
  770. }
  771. float
  772. max_load_factor() const noexcept
  773. { return _Base::max_load_factor(); }
  774. void
  775. max_load_factor(float __f)
  776. {
  777. __glibcxx_check_max_load_factor(__f);
  778. _Base::max_load_factor(__f);
  779. }
  780. template<typename... _Args>
  781. iterator
  782. emplace(_Args&&... __args)
  783. {
  784. size_type __bucket_count = this->bucket_count();
  785. auto __it = _Base::emplace(std::forward<_Args>(__args)...);
  786. _M_check_rehashed(__bucket_count);
  787. return { __it, this };
  788. }
  789. template<typename... _Args>
  790. iterator
  791. emplace_hint(const_iterator __hint, _Args&&... __args)
  792. {
  793. __glibcxx_check_insert(__hint);
  794. size_type __bucket_count = this->bucket_count();
  795. auto __it = _Base::emplace_hint(__hint.base(),
  796. std::forward<_Args>(__args)...);
  797. _M_check_rehashed(__bucket_count);
  798. return { __it, this };
  799. }
  800. iterator
  801. insert(const value_type& __obj)
  802. {
  803. size_type __bucket_count = this->bucket_count();
  804. auto __it = _Base::insert(__obj);
  805. _M_check_rehashed(__bucket_count);
  806. return { __it, this };
  807. }
  808. iterator
  809. insert(const_iterator __hint, const value_type& __obj)
  810. {
  811. __glibcxx_check_insert(__hint);
  812. size_type __bucket_count = this->bucket_count();
  813. auto __it = _Base::insert(__hint.base(), __obj);
  814. _M_check_rehashed(__bucket_count);
  815. return { __it, this };
  816. }
  817. iterator
  818. insert(value_type&& __obj)
  819. {
  820. size_type __bucket_count = this->bucket_count();
  821. auto __it = _Base::insert(std::move(__obj));
  822. _M_check_rehashed(__bucket_count);
  823. return { __it, this };
  824. }
  825. iterator
  826. insert(const_iterator __hint, value_type&& __obj)
  827. {
  828. __glibcxx_check_insert(__hint);
  829. size_type __bucket_count = this->bucket_count();
  830. auto __it = _Base::insert(__hint.base(), std::move(__obj));
  831. _M_check_rehashed(__bucket_count);
  832. return { __it, this };
  833. }
  834. void
  835. insert(std::initializer_list<value_type> __l)
  836. {
  837. size_type __bucket_count = this->bucket_count();
  838. _Base::insert(__l);
  839. _M_check_rehashed(__bucket_count);
  840. }
  841. template<typename _InputIterator>
  842. void
  843. insert(_InputIterator __first, _InputIterator __last)
  844. {
  845. typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
  846. __glibcxx_check_valid_range2(__first, __last, __dist);
  847. size_type __bucket_count = this->bucket_count();
  848. if (__dist.second >= __gnu_debug::__dp_sign)
  849. _Base::insert(__gnu_debug::__unsafe(__first),
  850. __gnu_debug::__unsafe(__last));
  851. else
  852. _Base::insert(__first, __last);
  853. _M_check_rehashed(__bucket_count);
  854. }
  855. #if __cplusplus > 201402L
  856. using node_type = typename _Base::node_type;
  857. node_type
  858. extract(const_iterator __position)
  859. {
  860. __glibcxx_check_erase(__position);
  861. return _M_extract(__position.base());
  862. }
  863. node_type
  864. extract(const key_type& __key)
  865. {
  866. const auto __position = _Base::find(__key);
  867. if (__position != _Base::end())
  868. return _M_extract(__position);
  869. return {};
  870. }
  871. iterator
  872. insert(node_type&& __nh)
  873. { return { _Base::insert(std::move(__nh)), this }; }
  874. iterator
  875. insert(const_iterator __hint, node_type&& __nh)
  876. {
  877. __glibcxx_check_insert(__hint);
  878. return { _Base::insert(__hint.base(), std::move(__nh)), this };
  879. }
  880. using _Base::merge;
  881. #endif // C++17
  882. iterator
  883. find(const key_type& __key)
  884. { return { _Base::find(__key), this }; }
  885. #if __cplusplus > 201703L
  886. template<typename _Kt,
  887. typename = std::__has_is_transparent_t<_Hash, _Kt>,
  888. typename = std::__has_is_transparent_t<_Pred, _Kt>>
  889. iterator
  890. find(const _Kt& __k)
  891. { return { _Base::find(__k), this }; }
  892. #endif
  893. const_iterator
  894. find(const key_type& __key) const
  895. { return { _Base::find(__key), this }; }
  896. #if __cplusplus > 201703L
  897. template<typename _Kt,
  898. typename = std::__has_is_transparent_t<_Hash, _Kt>,
  899. typename = std::__has_is_transparent_t<_Pred, _Kt>>
  900. const_iterator
  901. find(const _Kt& __k) const
  902. { return { _Base::find(__k), this }; }
  903. #endif
  904. std::pair<iterator, iterator>
  905. equal_range(const key_type& __key)
  906. {
  907. auto __res = _Base::equal_range(__key);
  908. return { { __res.first, this }, { __res.second, this } };
  909. }
  910. #if __cplusplus > 201703L
  911. template<typename _Kt,
  912. typename = std::__has_is_transparent_t<_Hash, _Kt>,
  913. typename = std::__has_is_transparent_t<_Pred, _Kt>>
  914. std::pair<iterator, iterator>
  915. equal_range(const _Kt& __k)
  916. {
  917. auto __res = _Base::equal_range(__k);
  918. return { { __res.first, this }, { __res.second, this } };
  919. }
  920. #endif
  921. std::pair<const_iterator, const_iterator>
  922. equal_range(const key_type& __key) const
  923. {
  924. auto __res = _Base::equal_range(__key);
  925. return { { __res.first, this }, { __res.second, this } };
  926. }
  927. #if __cplusplus > 201703L
  928. template<typename _Kt,
  929. typename = std::__has_is_transparent_t<_Hash, _Kt>,
  930. typename = std::__has_is_transparent_t<_Pred, _Kt>>
  931. std::pair<const_iterator, const_iterator>
  932. equal_range(const _Kt& __k) const
  933. {
  934. auto __res = _Base::equal_range(__k);
  935. return { { __res.first, this }, { __res.second, this } };
  936. }
  937. #endif
  938. size_type
  939. erase(const key_type& __key)
  940. {
  941. size_type __ret(0);
  942. auto __pair = _Base::equal_range(__key);
  943. for (auto __victim = __pair.first; __victim != __pair.second;)
  944. {
  945. _M_invalidate(__victim);
  946. __victim = _Base::erase(__victim);
  947. ++__ret;
  948. }
  949. return __ret;
  950. }
  951. iterator
  952. erase(const_iterator __it)
  953. {
  954. __glibcxx_check_erase(__it);
  955. return { _M_erase(__it.base()), this };
  956. }
  957. iterator
  958. erase(iterator __it)
  959. {
  960. __glibcxx_check_erase(__it);
  961. return { _M_erase(__it.base()), this };
  962. }
  963. iterator
  964. erase(const_iterator __first, const_iterator __last)
  965. {
  966. __glibcxx_check_erase_range(__first, __last);
  967. for (auto __tmp = __first.base(); __tmp != __last.base(); ++__tmp)
  968. {
  969. _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(),
  970. _M_message(__gnu_debug::__msg_valid_range)
  971. ._M_iterator(__first, "first")
  972. ._M_iterator(__last, "last"));
  973. _M_invalidate(__tmp);
  974. }
  975. return { _Base::erase(__first.base(), __last.base()), this };
  976. }
  977. _Base&
  978. _M_base() noexcept { return *this; }
  979. const _Base&
  980. _M_base() const noexcept { return *this; }
  981. private:
  982. void
  983. _M_check_rehashed(size_type __prev_count)
  984. {
  985. if (__prev_count != this->bucket_count())
  986. this->_M_invalidate_all();
  987. }
  988. void
  989. _M_invalidate(_Base_const_iterator __victim)
  990. {
  991. this->_M_invalidate_if(
  992. [__victim](_Base_const_iterator __it) { return __it == __victim; });
  993. this->_M_invalidate_local_if(
  994. [__victim](_Base_const_local_iterator __it)
  995. { return __it == __victim; });
  996. }
  997. _Base_iterator
  998. _M_erase(_Base_const_iterator __victim)
  999. {
  1000. _M_invalidate(__victim);
  1001. size_type __bucket_count = this->bucket_count();
  1002. _Base_iterator __next = _Base::erase(__victim);
  1003. _M_check_rehashed(__bucket_count);
  1004. return __next;
  1005. }
  1006. #if __cplusplus > 201402L
  1007. node_type
  1008. _M_extract(_Base_const_iterator __victim)
  1009. {
  1010. _M_invalidate(__victim);
  1011. return _Base::extract(__victim);
  1012. }
  1013. #endif
  1014. };
  1015. #if __cpp_deduction_guides >= 201606
  1016. template<typename _InputIterator,
  1017. typename _Hash =
  1018. hash<typename iterator_traits<_InputIterator>::value_type>,
  1019. typename _Pred =
  1020. equal_to<typename iterator_traits<_InputIterator>::value_type>,
  1021. typename _Allocator =
  1022. allocator<typename iterator_traits<_InputIterator>::value_type>,
  1023. typename = _RequireInputIter<_InputIterator>,
  1024. typename = _RequireNotAllocatorOrIntegral<_Hash>,
  1025. typename = _RequireNotAllocator<_Pred>,
  1026. typename = _RequireAllocator<_Allocator>>
  1027. unordered_multiset(_InputIterator, _InputIterator,
  1028. unordered_multiset<int>::size_type = {},
  1029. _Hash = _Hash(), _Pred = _Pred(),
  1030. _Allocator = _Allocator())
  1031. -> unordered_multiset<typename iterator_traits<_InputIterator>::value_type,
  1032. _Hash, _Pred, _Allocator>;
  1033. template<typename _Tp, typename _Hash = hash<_Tp>,
  1034. typename _Pred = equal_to<_Tp>,
  1035. typename _Allocator = allocator<_Tp>,
  1036. typename = _RequireNotAllocatorOrIntegral<_Hash>,
  1037. typename = _RequireNotAllocator<_Pred>,
  1038. typename = _RequireAllocator<_Allocator>>
  1039. unordered_multiset(initializer_list<_Tp>,
  1040. unordered_multiset<int>::size_type = {},
  1041. _Hash = _Hash(), _Pred = _Pred(),
  1042. _Allocator = _Allocator())
  1043. -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>;
  1044. template<typename _InputIterator, typename _Allocator,
  1045. typename = _RequireInputIter<_InputIterator>,
  1046. typename = _RequireAllocator<_Allocator>>
  1047. unordered_multiset(_InputIterator, _InputIterator,
  1048. unordered_multiset<int>::size_type, _Allocator)
  1049. -> unordered_multiset<typename iterator_traits<_InputIterator>::value_type,
  1050. hash<typename
  1051. iterator_traits<_InputIterator>::value_type>,
  1052. equal_to<typename
  1053. iterator_traits<_InputIterator>::value_type>,
  1054. _Allocator>;
  1055. template<typename _InputIterator, typename _Hash, typename _Allocator,
  1056. typename = _RequireInputIter<_InputIterator>,
  1057. typename = _RequireNotAllocatorOrIntegral<_Hash>,
  1058. typename = _RequireAllocator<_Allocator>>
  1059. unordered_multiset(_InputIterator, _InputIterator,
  1060. unordered_multiset<int>::size_type,
  1061. _Hash, _Allocator)
  1062. -> unordered_multiset<typename
  1063. iterator_traits<_InputIterator>::value_type,
  1064. _Hash,
  1065. equal_to<
  1066. typename
  1067. iterator_traits<_InputIterator>::value_type>,
  1068. _Allocator>;
  1069. template<typename _Tp, typename _Allocator,
  1070. typename = _RequireAllocator<_Allocator>>
  1071. unordered_multiset(initializer_list<_Tp>,
  1072. unordered_multiset<int>::size_type, _Allocator)
  1073. -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
  1074. template<typename _Tp, typename _Hash, typename _Allocator,
  1075. typename = _RequireNotAllocatorOrIntegral<_Hash>,
  1076. typename = _RequireAllocator<_Allocator>>
  1077. unordered_multiset(initializer_list<_Tp>,
  1078. unordered_multiset<int>::size_type, _Hash, _Allocator)
  1079. -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
  1080. #endif
  1081. template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
  1082. inline void
  1083. swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
  1084. unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
  1085. noexcept(noexcept(__x.swap(__y)))
  1086. { __x.swap(__y); }
  1087. template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
  1088. inline bool
  1089. operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
  1090. const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
  1091. { return __x._M_base() == __y._M_base(); }
  1092. #if __cpp_impl_three_way_comparison < 201907L
  1093. template<typename _Value, typename _Hash, typename _Pred, typename _Alloc>
  1094. inline bool
  1095. operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
  1096. const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
  1097. { return !(__x == __y); }
  1098. #endif
  1099. } // namespace __debug
  1100. } // namespace std
  1101. #endif // C++11
  1102. #endif