safe_iterator.tcc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. // Debugging iterator implementation (out of line) -*- 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/safe_iterator.tcc
  21. * This file is a GNU debug extension to the Standard C++ Library.
  22. */
  23. #ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_TCC
  24. #define _GLIBCXX_DEBUG_SAFE_ITERATOR_TCC 1
  25. #include <bits/stl_algobase.h>
  26. namespace __gnu_debug
  27. {
  28. template<typename _Iterator, typename _Sequence, typename _Category>
  29. typename _Distance_traits<_Iterator>::__type
  30. _Safe_iterator<_Iterator, _Sequence, _Category>::
  31. _M_get_distance_from_begin() const
  32. {
  33. typedef _Sequence_traits<_Sequence> _SeqTraits;
  34. // No need to consider before_begin as this function is only used in
  35. // _M_can_advance which won't be used for forward_list iterators.
  36. if (_M_is_begin())
  37. return std::make_pair(0, __dp_exact);
  38. if (_M_is_end())
  39. return _SeqTraits::_S_size(*_M_get_sequence());
  40. typename _Distance_traits<_Iterator>::__type __res
  41. = __get_distance(_M_get_sequence()->_M_base().begin(), base());
  42. if (__res.second == __dp_equality)
  43. return std::make_pair(1, __dp_sign);
  44. return __res;
  45. }
  46. template<typename _Iterator, typename _Sequence, typename _Category>
  47. typename _Distance_traits<_Iterator>::__type
  48. _Safe_iterator<_Iterator, _Sequence, _Category>::
  49. _M_get_distance_to_end() const
  50. {
  51. typedef _Sequence_traits<_Sequence> _SeqTraits;
  52. // No need to consider before_begin as this function is only used in
  53. // _M_can_advance which won't be used for forward_list iterators.
  54. if (_M_is_begin())
  55. return _SeqTraits::_S_size(*_M_get_sequence());
  56. if (_M_is_end())
  57. return std::make_pair(0, __dp_exact);
  58. typename _Distance_traits<_Iterator>::__type __res
  59. = __get_distance(base(), _M_get_sequence()->_M_base().end());
  60. if (__res.second == __dp_equality)
  61. return std::make_pair(1, __dp_sign);
  62. return __res;
  63. }
  64. template<typename _Iterator, typename _Sequence, typename _Category>
  65. bool
  66. _Safe_iterator<_Iterator, _Sequence, _Category>::
  67. _M_can_advance(difference_type __n, bool __strict) const
  68. {
  69. if (this->_M_singular())
  70. return false;
  71. if (__n == 0)
  72. return true;
  73. std::pair<difference_type, _Distance_precision> __dist = __n < 0
  74. ? _M_get_distance_from_begin()
  75. : _M_get_distance_to_end();
  76. if (__n < 0)
  77. __n = -__n;
  78. return __dist.second > __dp_sign
  79. ? __dist.first >= __n
  80. : !__strict && __dist.first > 0;
  81. }
  82. template<typename _Iterator, typename _Sequence, typename _Category>
  83. template<typename _Diff>
  84. bool
  85. _Safe_iterator<_Iterator, _Sequence, _Category>::
  86. _M_can_advance(const std::pair<_Diff, _Distance_precision>& __dist,
  87. int __way) const
  88. {
  89. return __dist.second == __dp_exact
  90. ? _M_can_advance(__way * __dist.first)
  91. : _M_can_advance(__way * (__dist.first == 0
  92. ? 0
  93. : __dist.first < 0 ? -1 : 1));
  94. }
  95. template<typename _Iterator, typename _Sequence, typename _Category>
  96. typename _Distance_traits<_Iterator>::__type
  97. _Safe_iterator<_Iterator, _Sequence, _Category>::
  98. _M_get_distance_to(const _Safe_iterator& __rhs) const
  99. {
  100. typedef typename _Distance_traits<_Iterator>::__type _Dist;
  101. typedef _Sequence_traits<_Sequence> _SeqTraits;
  102. _Dist __base_dist = __get_distance(this->base(), __rhs.base());
  103. if (__base_dist.second == __dp_exact)
  104. return __base_dist;
  105. _Dist __seq_dist = _SeqTraits::_S_size(*this->_M_get_sequence());
  106. if (this->_M_is_before_begin())
  107. {
  108. if (__rhs._M_is_begin())
  109. return std::make_pair(1, __dp_exact);
  110. return __seq_dist.second == __dp_exact
  111. ? std::make_pair(__seq_dist.first + 1, __dp_exact)
  112. : __seq_dist;
  113. }
  114. if (this->_M_is_begin())
  115. {
  116. if (__rhs._M_is_before_begin())
  117. return std::make_pair(-1, __dp_exact);
  118. if (__rhs._M_is_end())
  119. return __seq_dist;
  120. return std::make_pair(__seq_dist.first,
  121. __seq_dist.second == __dp_exact
  122. ? __dp_sign_max_size : __seq_dist.second);
  123. }
  124. if (this->_M_is_end())
  125. {
  126. if (__rhs._M_is_before_begin())
  127. return __seq_dist.second == __dp_exact
  128. ? std::make_pair(-__seq_dist.first - 1, __dp_exact)
  129. : std::make_pair(-__seq_dist.first, __dp_sign);
  130. if (__rhs._M_is_begin())
  131. return std::make_pair(-__seq_dist.first, __seq_dist.second);
  132. return std::make_pair(-__seq_dist.first,
  133. __seq_dist.second == __dp_exact
  134. ? __dp_sign_max_size : __seq_dist.second);
  135. }
  136. if (__rhs._M_is_before_begin())
  137. return __seq_dist.second == __dp_exact
  138. ? std::make_pair(__seq_dist.first - 1, __dp_exact)
  139. : std::make_pair(-__seq_dist.first, __dp_sign);
  140. if (__rhs._M_is_begin())
  141. return std::make_pair(-__seq_dist.first,
  142. __seq_dist.second == __dp_exact
  143. ? __dp_sign_max_size : __seq_dist.second);
  144. if (__rhs._M_is_end())
  145. return std::make_pair(__seq_dist.first,
  146. __seq_dist.second == __dp_exact
  147. ? __dp_sign_max_size : __seq_dist.second);
  148. return std::make_pair(1, __dp_equality);
  149. }
  150. template<typename _Iterator, typename _Sequence, typename _Category>
  151. bool
  152. _Safe_iterator<_Iterator, _Sequence, _Category>::
  153. _M_valid_range(const _Safe_iterator& __rhs,
  154. std::pair<difference_type, _Distance_precision>& __dist,
  155. bool __check_dereferenceable) const
  156. {
  157. if (_M_singular() || __rhs._M_singular() || !_M_can_compare(__rhs))
  158. return false;
  159. /* Determine iterators order */
  160. __dist = _M_get_distance_to(__rhs);
  161. if (__dist.second != __dp_equality)
  162. {
  163. // If range is not empty first iterator must be dereferenceable.
  164. return __dist.first == 0
  165. || (__dist.first > 0
  166. && (!__check_dereferenceable || _M_dereferenceable()));
  167. }
  168. // Assume that this is a valid range; we can't check anything else.
  169. return true;
  170. }
  171. template<typename _Iterator, typename _Sequence>
  172. bool
  173. _Safe_iterator<_Iterator, _Sequence, std::random_access_iterator_tag>::
  174. _M_valid_range(const _Safe_iterator& __rhs,
  175. std::pair<difference_type,
  176. _Distance_precision>& __dist) const
  177. {
  178. if (this->_M_singular() || __rhs._M_singular()
  179. || !this->_M_can_compare(__rhs))
  180. return false;
  181. /* Determine iterators order */
  182. __dist = std::make_pair(__rhs.base() - this->base(), __dp_exact);
  183. // If range is not empty first iterator must be dereferenceable.
  184. return __dist.first == 0
  185. || (__dist.first > 0 && this->_M_dereferenceable());
  186. }
  187. } // namespace __gnu_debug
  188. namespace std _GLIBCXX_VISIBILITY(default)
  189. {
  190. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  191. template<typename _Ite, typename _Seq>
  192. _Ite
  193. __niter_base(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq,
  194. std::random_access_iterator_tag>& __it)
  195. { return __it.base(); }
  196. template<bool _IsMove,
  197. typename _Ite, typename _Seq, typename _Cat, typename _OI>
  198. _OI
  199. __copy_move_a(
  200. const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first,
  201. const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __last,
  202. _OI __result)
  203. {
  204. typename ::__gnu_debug::_Distance_traits<_Ite>::__type __dist;
  205. __glibcxx_check_valid_range2(__first, __last, __dist);
  206. __glibcxx_check_can_increment_dist(__result, __dist, 1);
  207. if (__dist.second > ::__gnu_debug::__dp_equality)
  208. return std::__copy_move_a<_IsMove>(__first.base(), __last.base(),
  209. __result);
  210. return std::__copy_move_a1<_IsMove>(__first, __last, __result);
  211. }
  212. template<bool _IsMove,
  213. typename _II, typename _Ite, typename _Seq, typename _Cat>
  214. __gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>
  215. __copy_move_a(_II __first, _II __last,
  216. const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __result)
  217. {
  218. typename ::__gnu_debug::_Distance_traits<_II>::__type __dist;
  219. __glibcxx_check_valid_range2(__first, __last, __dist);
  220. __glibcxx_check_can_increment_dist(__result, __dist, 1);
  221. if (__dist.second > ::__gnu_debug::__dp_sign
  222. && __result._M_can_advance(__dist.first, true))
  223. return ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>(
  224. std::__copy_move_a<_IsMove>(__first, __last, __result.base()),
  225. __result._M_sequence);
  226. return std::__copy_move_a1<_IsMove>(__first, __last, __result);
  227. }
  228. template<bool _IsMove,
  229. typename _IIte, typename _ISeq, typename _ICat,
  230. typename _OIte, typename _OSeq, typename _OCat>
  231. ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>
  232. __copy_move_a(
  233. const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>& __first,
  234. const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>& __last,
  235. const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>& __result)
  236. {
  237. typename ::__gnu_debug::_Distance_traits<_IIte>::__type __dist;
  238. __glibcxx_check_valid_range2(__first, __last, __dist);
  239. __glibcxx_check_can_increment_dist(__result, __dist, 1);
  240. if (__dist.second > ::__gnu_debug::__dp_equality)
  241. {
  242. if (__dist.second > ::__gnu_debug::__dp_sign
  243. && __result._M_can_advance(__dist.first, true))
  244. return ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>(
  245. std::__copy_move_a<_IsMove>(__first.base(), __last.base(),
  246. __result.base()),
  247. __result._M_sequence);
  248. return std::__copy_move_a<_IsMove>(__first.base(), __last.base(),
  249. __result);
  250. }
  251. return std::__copy_move_a1<_IsMove>(__first, __last, __result);
  252. }
  253. template<bool _IsMove,
  254. typename _Ite, typename _Seq, typename _Cat, typename _OI>
  255. _OI
  256. __copy_move_backward_a(
  257. const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first,
  258. const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __last,
  259. _OI __result)
  260. {
  261. typename ::__gnu_debug::_Distance_traits<_Ite>::__type __dist;
  262. __glibcxx_check_valid_range2(__first, __last, __dist);
  263. __glibcxx_check_can_increment_dist(__result, __dist, -1);
  264. if (__dist.second > ::__gnu_debug::__dp_equality)
  265. return std::__copy_move_backward_a<_IsMove>(
  266. __first.base(), __last.base(), __result);
  267. return std::__copy_move_backward_a1<_IsMove>(__first, __last, __result);
  268. }
  269. template<bool _IsMove,
  270. typename _II, typename _Ite, typename _Seq, typename _Cat>
  271. __gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>
  272. __copy_move_backward_a(_II __first, _II __last,
  273. const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __result)
  274. {
  275. typename ::__gnu_debug::_Distance_traits<_II>::__type __dist;
  276. __glibcxx_check_valid_range2(__first, __last, __dist);
  277. __glibcxx_check_can_increment_dist(__result, __dist, -1);
  278. if (__dist.second > ::__gnu_debug::__dp_sign
  279. && __result._M_can_advance(-__dist.first, true))
  280. return ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>(
  281. std::__copy_move_backward_a<_IsMove>(__first, __last,
  282. __result.base()),
  283. __result._M_sequence);
  284. return std::__copy_move_backward_a1<_IsMove>(__first, __last, __result);
  285. }
  286. template<bool _IsMove,
  287. typename _IIte, typename _ISeq, typename _ICat,
  288. typename _OIte, typename _OSeq, typename _OCat>
  289. ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>
  290. __copy_move_backward_a(
  291. const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>& __first,
  292. const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>& __last,
  293. const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>& __result)
  294. {
  295. typename ::__gnu_debug::_Distance_traits<_IIte>::__type __dist;
  296. __glibcxx_check_valid_range2(__first, __last, __dist);
  297. __glibcxx_check_can_increment_dist(__result, __dist, -1);
  298. if (__dist.second > ::__gnu_debug::__dp_equality)
  299. {
  300. if (__dist.second > ::__gnu_debug::__dp_sign
  301. && __result._M_can_advance(-__dist.first, true))
  302. return ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>(
  303. std::__copy_move_backward_a<_IsMove>(__first.base(), __last.base(),
  304. __result.base()),
  305. __result._M_sequence);
  306. return std::__copy_move_backward_a<_IsMove>(
  307. __first.base(), __last.base(), __result);
  308. }
  309. return std::__copy_move_backward_a1<_IsMove>(__first, __last, __result);
  310. }
  311. template<typename _Ite, typename _Seq, typename _Cat, typename _Tp>
  312. void
  313. __fill_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first,
  314. const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __last,
  315. const _Tp& __value)
  316. {
  317. typename ::__gnu_debug::_Distance_traits<_Ite>::__type __dist;
  318. __glibcxx_check_valid_range2(__first, __last, __dist);
  319. if (__dist.second > ::__gnu_debug::__dp_equality)
  320. std::__fill_a(__first.base(), __last.base(), __value);
  321. std::__fill_a1(__first, __last, __value);
  322. }
  323. template<typename _Ite, typename _Seq, typename _Cat, typename _Size,
  324. typename _Tp>
  325. ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>
  326. __fill_n_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first,
  327. _Size __n, const _Tp& __value,
  328. std::input_iterator_tag)
  329. {
  330. #if __cplusplus >= 201103L
  331. static_assert(is_integral<_Size>{}, "fill_n must pass integral size");
  332. #endif
  333. if (__n <= 0)
  334. return __first;
  335. __glibcxx_check_can_increment(__first, __n);
  336. if (__first._M_can_advance(__n, true))
  337. return ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>(
  338. std::__fill_n_a(__first.base(), __n, __value, _Cat()),
  339. __first._M_sequence);
  340. return std::__fill_n_a1(__first, __n, __value);
  341. }
  342. template<typename _II1, typename _Seq1, typename _Cat1, typename _II2>
  343. bool
  344. __equal_aux(
  345. const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>& __first1,
  346. const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>& __last1,
  347. _II2 __first2)
  348. {
  349. typename ::__gnu_debug::_Distance_traits<_II1>::__type __dist;
  350. __glibcxx_check_valid_range2(__first1, __last1, __dist);
  351. __glibcxx_check_can_increment_dist(__first2, __dist, 1);
  352. if (__dist.second > ::__gnu_debug::__dp_equality)
  353. return std::__equal_aux(__first1.base(), __last1.base(), __first2);
  354. return std::__equal_aux1(__first1, __last1, __first2);
  355. }
  356. template<typename _II1, typename _II2, typename _Seq2, typename _Cat2>
  357. bool
  358. __equal_aux(_II1 __first1, _II1 __last1,
  359. const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>& __first2)
  360. {
  361. typename ::__gnu_debug::_Distance_traits<_II1>::__type __dist;
  362. __glibcxx_check_valid_range2(__first1, __last1, __dist);
  363. __glibcxx_check_can_increment_dist(__first2, __dist, 1);
  364. if (__dist.second > ::__gnu_debug::__dp_sign
  365. && __first2._M_can_advance(__dist.first, true))
  366. return std::__equal_aux(__first1, __last1, __first2.base());
  367. return std::__equal_aux1(__first1, __last1, __first2);
  368. }
  369. template<typename _II1, typename _Seq1, typename _Cat1,
  370. typename _II2, typename _Seq2, typename _Cat2>
  371. bool
  372. __equal_aux(
  373. const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>& __first1,
  374. const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>& __last1,
  375. const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>& __first2)
  376. {
  377. typename ::__gnu_debug::_Distance_traits<_II1>::__type __dist;
  378. __glibcxx_check_valid_range2(__first1, __last1, __dist);
  379. __glibcxx_check_can_increment_dist(__first2, __dist, 1);
  380. if (__dist.second > ::__gnu_debug::__dp_equality)
  381. {
  382. if (__dist.second > ::__gnu_debug::__dp_sign &&
  383. __first2._M_can_advance(__dist.first, true))
  384. return std::__equal_aux(__first1.base(), __last1.base(),
  385. __first2.base());
  386. return std::__equal_aux(__first1.base(), __last1.base(), __first2);
  387. }
  388. return __equal_aux1(__first1, __last1, __first2);
  389. }
  390. template<typename _Ite1, typename _Seq1, typename _Cat1,
  391. typename _II2>
  392. bool
  393. __lexicographical_compare_aux(
  394. const ::__gnu_debug::_Safe_iterator<_Ite1, _Seq1, _Cat1>& __first1,
  395. const ::__gnu_debug::_Safe_iterator<_Ite1, _Seq1, _Cat1>& __last1,
  396. _II2 __first2, _II2 __last2)
  397. {
  398. typename ::__gnu_debug::_Distance_traits<_Ite1>::__type __dist1;
  399. __glibcxx_check_valid_range2(__first1, __last1, __dist1);
  400. __glibcxx_check_valid_range(__first2, __last2);
  401. if (__dist1.second > ::__gnu_debug::__dp_equality)
  402. return std::__lexicographical_compare_aux(__first1.base(),
  403. __last1.base(),
  404. __first2, __last2);
  405. return std::__lexicographical_compare_aux1(__first1, __last1,
  406. __first2, __last2);
  407. }
  408. template<typename _II1,
  409. typename _Ite2, typename _Seq2, typename _Cat2>
  410. bool
  411. __lexicographical_compare_aux(
  412. _II1 __first1, _II1 __last1,
  413. const ::__gnu_debug::_Safe_iterator<_Ite2, _Seq2, _Cat2>& __first2,
  414. const ::__gnu_debug::_Safe_iterator<_Ite2, _Seq2, _Cat2>& __last2)
  415. {
  416. __glibcxx_check_valid_range(__first1, __last1);
  417. typename ::__gnu_debug::_Distance_traits<_II1>::__type __dist2;
  418. __glibcxx_check_valid_range2(__first2, __last2, __dist2);
  419. if (__dist2.second > ::__gnu_debug::__dp_equality)
  420. return std::__lexicographical_compare_aux(__first1, __last1,
  421. __first2.base(),
  422. __last2.base());
  423. return std::__lexicographical_compare_aux1(__first1, __last1,
  424. __first2, __last2);
  425. }
  426. template<typename _Ite1, typename _Seq1, typename _Cat1,
  427. typename _Ite2, typename _Seq2, typename _Cat2>
  428. bool
  429. __lexicographical_compare_aux(
  430. const ::__gnu_debug::_Safe_iterator<_Ite1, _Seq1, _Cat1>& __first1,
  431. const ::__gnu_debug::_Safe_iterator<_Ite1, _Seq1, _Cat1>& __last1,
  432. const ::__gnu_debug::_Safe_iterator<_Ite2, _Seq2, _Cat2>& __first2,
  433. const ::__gnu_debug::_Safe_iterator<_Ite2, _Seq2, _Cat2>& __last2)
  434. {
  435. typename ::__gnu_debug::_Distance_traits<_Ite1>::__type __dist1;
  436. __glibcxx_check_valid_range2(__first1, __last1, __dist1);
  437. typename ::__gnu_debug::_Distance_traits<_Ite2>::__type __dist2;
  438. __glibcxx_check_valid_range2(__first2, __last2, __dist2);
  439. if (__dist1.second > ::__gnu_debug::__dp_equality)
  440. {
  441. if (__dist2.second > ::__gnu_debug::__dp_equality)
  442. return std::__lexicographical_compare_aux(__first1.base(),
  443. __last1.base(),
  444. __first2.base(),
  445. __last2.base());
  446. return std::__lexicographical_compare_aux(__first1.base(),
  447. __last1.base(),
  448. __first2, __last2);
  449. }
  450. if (__dist2.second > ::__gnu_debug::__dp_equality)
  451. return std::__lexicographical_compare_aux(__first1, __last1,
  452. __first2.base(),
  453. __last2.base());
  454. return std::__lexicographical_compare_aux1(__first1, __last1,
  455. __first2, __last2);
  456. }
  457. _GLIBCXX_END_NAMESPACE_VERSION
  458. } // namespace std
  459. #endif