macros.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. // Debugging support 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/macros.h
  21. * This file is a GNU debug extension to the Standard C++ Library.
  22. */
  23. #ifndef _GLIBCXX_DEBUG_MACROS_H
  24. #define _GLIBCXX_DEBUG_MACROS_H 1
  25. /**
  26. * Macros used by the implementation to verify certain
  27. * properties. These macros may only be used directly by the debug
  28. * wrappers. Note that these are macros (instead of the more obviously
  29. * @a correct choice of making them functions) because we need line and
  30. * file information at the call site, to minimize the distance between
  31. * the user error and where the error is reported.
  32. *
  33. */
  34. #define _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func) \
  35. if (__builtin_expect(!bool(_Cond), false)) \
  36. __gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func) \
  37. ._ErrMsg._M_error()
  38. #define _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,_Func) \
  39. do { \
  40. __glibcxx_assert_1(_Cond) \
  41. { _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func); } \
  42. } while (false)
  43. #define _GLIBCXX_DEBUG_VERIFY_AT(_Cond,_ErrMsg,_File,_Line) \
  44. _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,__PRETTY_FUNCTION__)
  45. #define _GLIBCXX_DEBUG_VERIFY(_Cond,_ErrMsg) \
  46. _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond, _ErrMsg, __FILE__, __LINE__, \
  47. __PRETTY_FUNCTION__)
  48. // Verify that [_First, _Last) forms a valid iterator range.
  49. #define __glibcxx_check_valid_range(_First,_Last) \
  50. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \
  51. _M_message(__gnu_debug::__msg_valid_range) \
  52. ._M_iterator(_First, #_First) \
  53. ._M_iterator(_Last, #_Last))
  54. #define __glibcxx_check_valid_range_at(_First,_Last,_File,_Line,_Func) \
  55. _GLIBCXX_DEBUG_VERIFY_AT_F(__gnu_debug::__valid_range(_First, _Last), \
  56. _M_message(__gnu_debug::__msg_valid_range) \
  57. ._M_iterator(_First, #_First) \
  58. ._M_iterator(_Last, #_Last), \
  59. _File,_Line,_Func)
  60. #define __glibcxx_check_valid_range2(_First,_Last,_Dist) \
  61. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last, _Dist), \
  62. _M_message(__gnu_debug::__msg_valid_range) \
  63. ._M_iterator(_First, #_First) \
  64. ._M_iterator(_Last, #_Last))
  65. #define __glibcxx_check_valid_constructor_range(_First,_Last) \
  66. __gnu_debug::__check_valid_range(_First, _Last, \
  67. __FILE__, __LINE__, __PRETTY_FUNCTION__)
  68. // Verify that [_First, _Last) forms a non-empty iterator range.
  69. #define __glibcxx_check_non_empty_range(_First,_Last) \
  70. _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
  71. _M_message(__gnu_debug::__msg_non_empty_range) \
  72. ._M_iterator(_First, #_First) \
  73. ._M_iterator(_Last, #_Last))
  74. // Verify that [_First, _First + _Size) forms a valid range.
  75. #define __glibcxx_check_can_increment(_First,_Size) \
  76. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__can_advance(_First, _Size), \
  77. _M_message(__gnu_debug::__msg_iter_subscript_oob) \
  78. ._M_iterator(_First, #_First) \
  79. ._M_integer(_Size, #_Size))
  80. #define __glibcxx_check_can_increment_dist(_First,_Dist,_Way) \
  81. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__can_advance(_First, _Dist, _Way), \
  82. _M_message(__gnu_debug::__msg_iter_subscript_oob) \
  83. ._M_iterator(_First, #_First) \
  84. ._M_integer(_Way * _Dist.first, #_Dist))
  85. #define __glibcxx_check_can_increment_range(_First1,_Last1,_First2) \
  86. do \
  87. { \
  88. typename __gnu_debug::_Distance_traits<__decltype(_First1)>::__type __dist;\
  89. _GLIBCXX_DEBUG_VERIFY_AT_F( \
  90. __gnu_debug::__valid_range(_First1, _Last1, __dist),\
  91. _M_message(__gnu_debug::__msg_valid_range) \
  92. ._M_iterator(_First1, #_First1) \
  93. ._M_iterator(_Last1, #_Last1), \
  94. __FILE__,__LINE__,__PRETTY_FUNCTION__); \
  95. _GLIBCXX_DEBUG_VERIFY_AT_F( \
  96. __gnu_debug::__can_advance(_First2, __dist, 1), \
  97. _M_message(__gnu_debug::__msg_iter_subscript_oob)\
  98. ._M_iterator(_First2, #_First2) \
  99. ._M_integer(__dist.first), \
  100. __FILE__,__LINE__,__PRETTY_FUNCTION__); \
  101. } while(false)
  102. #define __glibcxx_check_can_decrement_range(_First1,_Last1,_First2) \
  103. do \
  104. { \
  105. typename __gnu_debug::_Distance_traits<__decltype(_First1)>::__type __dist;\
  106. _GLIBCXX_DEBUG_VERIFY_AT_F( \
  107. __gnu_debug::__valid_range(_First1, _Last1, __dist),\
  108. _M_message(__gnu_debug::__msg_valid_range) \
  109. ._M_iterator(_First1, #_First1) \
  110. ._M_iterator(_Last1, #_Last1), \
  111. __FILE__,__LINE__,__PRETTY_FUNCTION__); \
  112. _GLIBCXX_DEBUG_VERIFY_AT_F( \
  113. __gnu_debug::__can_advance(_First2, __dist, -1), \
  114. _M_message(__gnu_debug::__msg_iter_subscript_oob)\
  115. ._M_iterator(_First2, #_First2) \
  116. ._M_integer(-__dist.first), \
  117. __FILE__,__LINE__,__PRETTY_FUNCTION__); \
  118. } while(false)
  119. /** Verify that we can insert into *this with the iterator _Position.
  120. * Insertion into a container at a specific position requires that
  121. * the iterator be nonsingular, either dereferenceable or past-the-end,
  122. * and that it reference the sequence we are inserting into. Note that
  123. * this macro is only valid when the container is a_Safe_sequence and
  124. * the iterator is a _Safe_iterator.
  125. */
  126. #define __glibcxx_check_insert(_Position) \
  127. _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \
  128. _M_message(__gnu_debug::__msg_insert_singular) \
  129. ._M_sequence(*this, "this") \
  130. ._M_iterator(_Position, #_Position)); \
  131. _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
  132. _M_message(__gnu_debug::__msg_insert_different) \
  133. ._M_sequence(*this, "this") \
  134. ._M_iterator(_Position, #_Position))
  135. /** Verify that we can insert into *this after the iterator _Position.
  136. * Insertion into a container after a specific position requires that
  137. * the iterator be nonsingular, either dereferenceable or before-begin,
  138. * and that it reference the sequence we are inserting into. Note that
  139. * this macro is only valid when the container is a_Safe_sequence and
  140. * the iterator is a _Safe_iterator.
  141. */
  142. #define __glibcxx_check_insert_after(_Position) \
  143. __glibcxx_check_insert(_Position); \
  144. _GLIBCXX_DEBUG_VERIFY(!_Position._M_is_end(), \
  145. _M_message(__gnu_debug::__msg_insert_after_end) \
  146. ._M_sequence(*this, "this") \
  147. ._M_iterator(_Position, #_Position))
  148. /** Verify that we can insert the values in the iterator range
  149. * [_First, _Last) into *this with the iterator _Position. Insertion
  150. * into a container at a specific position requires that the iterator
  151. * be nonsingular (i.e., either dereferenceable or past-the-end),
  152. * that it reference the sequence we are inserting into, and that the
  153. * iterator range [_First, _Last) is a valid (possibly empty)
  154. * range which does not reference the sequence we are inserting into.
  155. * Note that this macro is only valid when the container is a
  156. * _Safe_sequence and the _Position iterator is a _Safe_iterator.
  157. */
  158. #define __glibcxx_check_insert_range(_Position,_First,_Last,_Dist) \
  159. __glibcxx_check_valid_range2(_First,_Last,_Dist); \
  160. __glibcxx_check_insert(_Position); \
  161. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
  162. _M_message(__gnu_debug::__msg_insert_range_from_self)\
  163. ._M_iterator(_First, #_First) \
  164. ._M_iterator(_Last, #_Last) \
  165. ._M_sequence(*this, "this"))
  166. /** Verify that we can insert the values in the iterator range
  167. * [_First, _Last) into *this after the iterator _Position. Insertion
  168. * into a container after a specific position requires that the iterator
  169. * be nonsingular (i.e., either dereferenceable or past-the-end),
  170. * that it reference the sequence we are inserting into, and that the
  171. * iterator range [_First, _Last) is a valid (possibly empty)
  172. * range which does not reference the sequence we are inserting into.
  173. * Note that this macro is only valid when the container is a
  174. * _Safe_sequence and the _Position iterator is a _Safe_iterator.
  175. */
  176. #define __glibcxx_check_insert_range_after(_Position,_First,_Last,_Dist)\
  177. __glibcxx_check_valid_range2(_First,_Last,_Dist); \
  178. __glibcxx_check_insert_after(_Position); \
  179. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
  180. _M_message(__gnu_debug::__msg_insert_range_from_self)\
  181. ._M_iterator(_First, #_First) \
  182. ._M_iterator(_Last, #_Last) \
  183. ._M_sequence(*this, "this"))
  184. /** Verify that we can erase the element referenced by the iterator
  185. * _Position. We can erase the element if the _Position iterator is
  186. * dereferenceable and references this sequence.
  187. */
  188. #define __glibcxx_check_erase(_Position) \
  189. _GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \
  190. _M_message(__gnu_debug::__msg_erase_bad) \
  191. ._M_sequence(*this, "this") \
  192. ._M_iterator(_Position, #_Position)); \
  193. _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
  194. _M_message(__gnu_debug::__msg_erase_different) \
  195. ._M_sequence(*this, "this") \
  196. ._M_iterator(_Position, #_Position))
  197. /** Verify that we can erase the element after the iterator
  198. * _Position. We can erase the element if the _Position iterator is
  199. * before a dereferenceable one and references this sequence.
  200. */
  201. #define __glibcxx_check_erase_after(_Position) \
  202. _GLIBCXX_DEBUG_VERIFY(_Position._M_before_dereferenceable(), \
  203. _M_message(__gnu_debug::__msg_erase_after_bad) \
  204. ._M_sequence(*this, "this") \
  205. ._M_iterator(_Position, #_Position)); \
  206. _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
  207. _M_message(__gnu_debug::__msg_erase_different) \
  208. ._M_sequence(*this, "this") \
  209. ._M_iterator(_Position, #_Position))
  210. /** Verify that we can erase the elements in the iterator range
  211. * [_First, _Last). We can erase the elements if [_First, _Last) is a
  212. * valid iterator range within this sequence.
  213. */
  214. #define __glibcxx_check_erase_range(_First,_Last) \
  215. __glibcxx_check_valid_range(_First,_Last); \
  216. _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
  217. _M_message(__gnu_debug::__msg_erase_different) \
  218. ._M_sequence(*this, "this") \
  219. ._M_iterator(_First, #_First) \
  220. ._M_iterator(_Last, #_Last))
  221. /** Verify that we can erase the elements in the iterator range
  222. * (_First, _Last). We can erase the elements if (_First, _Last) is a
  223. * valid iterator range within this sequence.
  224. */
  225. #define __glibcxx_check_erase_range_after(_First,_Last) \
  226. _GLIBCXX_DEBUG_VERIFY(!_First._M_singular() && !_Last._M_singular(), \
  227. _M_message(__gnu_debug::__msg_erase_different) \
  228. ._M_sequence(*this, "this") \
  229. ._M_iterator(_First, #_First) \
  230. ._M_iterator(_Last, #_Last)); \
  231. _GLIBCXX_DEBUG_VERIFY(_First._M_can_compare(_Last), \
  232. _M_message(__gnu_debug::__msg_erase_different) \
  233. ._M_sequence(*this, "this") \
  234. ._M_iterator(_First, #_First) \
  235. ._M_iterator(_Last, #_Last)); \
  236. _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
  237. _M_message(__gnu_debug::__msg_erase_different) \
  238. ._M_sequence(*this, "this") \
  239. ._M_iterator(_First, #_First)); \
  240. _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
  241. _M_message(__gnu_debug::__msg_valid_range2) \
  242. ._M_sequence(*this, "this") \
  243. ._M_iterator(_First, #_First) \
  244. ._M_iterator(_Last, #_Last)); \
  245. _GLIBCXX_DEBUG_VERIFY(_First._M_incrementable(), \
  246. _M_message(__gnu_debug::__msg_valid_range2) \
  247. ._M_sequence(*this, "this") \
  248. ._M_iterator(_First, #_First) \
  249. ._M_iterator(_Last, #_Last)); \
  250. _GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(), \
  251. _M_message(__gnu_debug::__msg_valid_range2) \
  252. ._M_sequence(*this, "this") \
  253. ._M_iterator(_First, #_First) \
  254. ._M_iterator(_Last, #_Last)) \
  255. // Verify that the subscript _N is less than the container's size.
  256. #define __glibcxx_check_subscript(_N) \
  257. _GLIBCXX_DEBUG_VERIFY(_N < this->size(), \
  258. _M_message(__gnu_debug::__msg_subscript_oob) \
  259. ._M_sequence(*this, "this") \
  260. ._M_integer(_N, #_N) \
  261. ._M_integer(this->size(), "size"))
  262. // Verify that the bucket _N is less than the container's buckets count.
  263. #define __glibcxx_check_bucket_index(_N) \
  264. _GLIBCXX_DEBUG_VERIFY(_N < this->bucket_count(), \
  265. _M_message(__gnu_debug::__msg_bucket_index_oob) \
  266. ._M_sequence(*this, "this") \
  267. ._M_integer(_N, #_N) \
  268. ._M_integer(this->bucket_count(), "size"))
  269. // Verify that the container is nonempty
  270. #define __glibcxx_check_nonempty() \
  271. _GLIBCXX_DEBUG_VERIFY(! this->empty(), \
  272. _M_message(__gnu_debug::__msg_empty) \
  273. ._M_sequence(*this, "this"))
  274. // Verify that a predicate is irreflexive
  275. #define __glibcxx_check_irreflexive(_First,_Last) \
  276. _GLIBCXX_DEBUG_VERIFY(_First == _Last || !(*_First < *_First), \
  277. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  278. ._M_iterator_value_type(_First, "< operator type"))
  279. #if __cplusplus >= 201103L
  280. # define __glibcxx_check_irreflexive2(_First,_Last) \
  281. _GLIBCXX_DEBUG_VERIFY(_First == _Last \
  282. || __gnu_debug::__is_irreflexive(_First), \
  283. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  284. ._M_iterator_value_type(_First, "< operator type"))
  285. #else
  286. # define __glibcxx_check_irreflexive2(_First,_Last)
  287. #endif
  288. #define __glibcxx_check_irreflexive_pred(_First,_Last,_Pred) \
  289. _GLIBCXX_DEBUG_VERIFY(_First == _Last || !_Pred(*_First, *_First), \
  290. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  291. ._M_instance(_Pred, "functor") \
  292. ._M_iterator_value_type(_First, "ordered type"))
  293. #if __cplusplus >= 201103L
  294. # define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred) \
  295. _GLIBCXX_DEBUG_VERIFY(_First == _Last \
  296. ||__gnu_debug::__is_irreflexive_pred(_First, _Pred), \
  297. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  298. ._M_instance(_Pred, "functor") \
  299. ._M_iterator_value_type(_First, "ordered type"))
  300. #else
  301. # define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred)
  302. #endif
  303. // Verify that the iterator range [_First, _Last) is sorted
  304. #define __glibcxx_check_sorted(_First,_Last) \
  305. __glibcxx_check_valid_range(_First,_Last); \
  306. __glibcxx_check_irreflexive(_First,_Last); \
  307. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
  308. __gnu_debug::__base(_First), \
  309. __gnu_debug::__base(_Last)), \
  310. _M_message(__gnu_debug::__msg_unsorted) \
  311. ._M_iterator(_First, #_First) \
  312. ._M_iterator(_Last, #_Last))
  313. /** Verify that the iterator range [_First, _Last) is sorted by the
  314. predicate _Pred. */
  315. #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \
  316. __glibcxx_check_valid_range(_First,_Last); \
  317. __glibcxx_check_irreflexive_pred(_First,_Last,_Pred); \
  318. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
  319. __gnu_debug::__base(_First), \
  320. __gnu_debug::__base(_Last), _Pred), \
  321. _M_message(__gnu_debug::__msg_unsorted_pred) \
  322. ._M_iterator(_First, #_First) \
  323. ._M_iterator(_Last, #_Last) \
  324. ._M_string(#_Pred))
  325. // Special variant for std::merge, std::includes, std::set_*
  326. #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \
  327. __glibcxx_check_valid_range(_First1,_Last1); \
  328. _GLIBCXX_DEBUG_VERIFY( \
  329. __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
  330. __gnu_debug::__base(_Last1), _First2),\
  331. _M_message(__gnu_debug::__msg_unsorted) \
  332. ._M_iterator(_First1, #_First1) \
  333. ._M_iterator(_Last1, #_Last1))
  334. // Likewise with a _Pred.
  335. #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
  336. __glibcxx_check_valid_range(_First1,_Last1); \
  337. _GLIBCXX_DEBUG_VERIFY( \
  338. __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
  339. __gnu_debug::__base(_Last1), \
  340. _First2, _Pred), \
  341. _M_message(__gnu_debug::__msg_unsorted_pred) \
  342. ._M_iterator(_First1, #_First1) \
  343. ._M_iterator(_Last1, #_Last1) \
  344. ._M_string(#_Pred))
  345. /** Verify that the iterator range [_First, _Last) is partitioned
  346. w.r.t. the value _Value. */
  347. #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \
  348. __glibcxx_check_valid_range(_First,_Last); \
  349. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
  350. __gnu_debug::__base(_First), \
  351. __gnu_debug::__base(_Last), _Value), \
  352. _M_message(__gnu_debug::__msg_unpartitioned) \
  353. ._M_iterator(_First, #_First) \
  354. ._M_iterator(_Last, #_Last) \
  355. ._M_string(#_Value))
  356. #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \
  357. __glibcxx_check_valid_range(_First,_Last); \
  358. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
  359. __gnu_debug::__base(_First), \
  360. __gnu_debug::__base(_Last), _Value), \
  361. _M_message(__gnu_debug::__msg_unpartitioned) \
  362. ._M_iterator(_First, #_First) \
  363. ._M_iterator(_Last, #_Last) \
  364. ._M_string(#_Value))
  365. /** Verify that the iterator range [_First, _Last) is partitioned
  366. w.r.t. the value _Value and predicate _Pred. */
  367. #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
  368. __glibcxx_check_valid_range(_First,_Last); \
  369. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
  370. __gnu_debug::__base(_First), \
  371. __gnu_debug::__base(_Last), _Value, _Pred), \
  372. _M_message(__gnu_debug::__msg_unpartitioned_pred) \
  373. ._M_iterator(_First, #_First) \
  374. ._M_iterator(_Last, #_Last) \
  375. ._M_string(#_Pred) \
  376. ._M_string(#_Value))
  377. /** Verify that the iterator range [_First, _Last) is partitioned
  378. w.r.t. the value _Value and predicate _Pred. */
  379. #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
  380. __glibcxx_check_valid_range(_First,_Last); \
  381. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
  382. __gnu_debug::__base(_First), \
  383. __gnu_debug::__base(_Last), _Value, _Pred), \
  384. _M_message(__gnu_debug::__msg_unpartitioned_pred) \
  385. ._M_iterator(_First, #_First) \
  386. ._M_iterator(_Last, #_Last) \
  387. ._M_string(#_Pred) \
  388. ._M_string(#_Value))
  389. // Verify that the iterator range [_First, _Last) is a heap
  390. #define __glibcxx_check_heap(_First,_Last) \
  391. _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
  392. __gnu_debug::__base(_Last)), \
  393. _M_message(__gnu_debug::__msg_not_heap) \
  394. ._M_iterator(_First, #_First) \
  395. ._M_iterator(_Last, #_Last))
  396. /** Verify that the iterator range [_First, _Last) is a heap
  397. w.r.t. the predicate _Pred. */
  398. #define __glibcxx_check_heap_pred(_First,_Last,_Pred) \
  399. _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
  400. __gnu_debug::__base(_Last), \
  401. _Pred), \
  402. _M_message(__gnu_debug::__msg_not_heap_pred) \
  403. ._M_iterator(_First, #_First) \
  404. ._M_iterator(_Last, #_Last) \
  405. ._M_string(#_Pred))
  406. // Verify that load factor is positive
  407. #define __glibcxx_check_max_load_factor(_F) \
  408. _GLIBCXX_DEBUG_VERIFY(_F > 0.0f, \
  409. _M_message(__gnu_debug::__msg_valid_load_factor) \
  410. ._M_sequence(*this, "this"))
  411. #define __glibcxx_check_equal_allocs(_This, _Other) \
  412. _GLIBCXX_DEBUG_VERIFY(_This.get_allocator() == _Other.get_allocator(), \
  413. _M_message(__gnu_debug::__msg_equal_allocs) \
  414. ._M_sequence(_This, "this"))
  415. #define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_PEDASSERT(_String != 0)
  416. #define __glibcxx_check_string_len(_String,_Len) \
  417. _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)
  418. #endif