macros.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. // Debugging support 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/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_constexpr_assert(_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. #if __cplusplus >= 201103L
  198. # define __glibcxx_check_erase2(_CPosition) \
  199. _GLIBCXX_DEBUG_VERIFY(_CPosition != _M_base().cend(), \
  200. _M_message(__gnu_debug::__msg_erase_bad) \
  201. ._M_sequence(*this, "this") \
  202. ._M_iterator(_CPosition, #_CPosition));
  203. #endif
  204. /** Verify that we can erase the element after the iterator
  205. * _Position. We can erase the element if the _Position iterator is
  206. * before a dereferenceable one and references this sequence.
  207. */
  208. #define __glibcxx_check_erase_after(_Position) \
  209. _GLIBCXX_DEBUG_VERIFY(_Position._M_before_dereferenceable(), \
  210. _M_message(__gnu_debug::__msg_erase_after_bad) \
  211. ._M_sequence(*this, "this") \
  212. ._M_iterator(_Position, #_Position)); \
  213. _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
  214. _M_message(__gnu_debug::__msg_erase_different) \
  215. ._M_sequence(*this, "this") \
  216. ._M_iterator(_Position, #_Position))
  217. /** Verify that we can erase the elements in the iterator range
  218. * [_First, _Last). We can erase the elements if [_First, _Last) is a
  219. * valid iterator range within this sequence.
  220. */
  221. #define __glibcxx_check_erase_range(_First,_Last) \
  222. __glibcxx_check_valid_range(_First,_Last); \
  223. _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
  224. _M_message(__gnu_debug::__msg_erase_different) \
  225. ._M_sequence(*this, "this") \
  226. ._M_iterator(_First, #_First) \
  227. ._M_iterator(_Last, #_Last))
  228. /** Verify that we can erase the elements in the iterator range
  229. * (_First, _Last). We can erase the elements if (_First, _Last) is a
  230. * valid iterator range within this sequence.
  231. */
  232. #define __glibcxx_check_erase_range_after(_First,_Last) \
  233. _GLIBCXX_DEBUG_VERIFY(!_First._M_singular() && !_Last._M_singular(), \
  234. _M_message(__gnu_debug::__msg_erase_different) \
  235. ._M_sequence(*this, "this") \
  236. ._M_iterator(_First, #_First) \
  237. ._M_iterator(_Last, #_Last)); \
  238. _GLIBCXX_DEBUG_VERIFY(_First._M_can_compare(_Last), \
  239. _M_message(__gnu_debug::__msg_erase_different) \
  240. ._M_sequence(*this, "this") \
  241. ._M_iterator(_First, #_First) \
  242. ._M_iterator(_Last, #_Last)); \
  243. _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
  244. _M_message(__gnu_debug::__msg_erase_different) \
  245. ._M_sequence(*this, "this") \
  246. ._M_iterator(_First, #_First)); \
  247. _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
  248. _M_message(__gnu_debug::__msg_valid_range2) \
  249. ._M_sequence(*this, "this") \
  250. ._M_iterator(_First, #_First) \
  251. ._M_iterator(_Last, #_Last)); \
  252. _GLIBCXX_DEBUG_VERIFY(_First._M_incrementable(), \
  253. _M_message(__gnu_debug::__msg_valid_range2) \
  254. ._M_sequence(*this, "this") \
  255. ._M_iterator(_First, #_First) \
  256. ._M_iterator(_Last, #_Last)); \
  257. _GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(), \
  258. _M_message(__gnu_debug::__msg_valid_range2) \
  259. ._M_sequence(*this, "this") \
  260. ._M_iterator(_First, #_First) \
  261. ._M_iterator(_Last, #_Last)) \
  262. // Verify that the subscript _N is less than the container's size.
  263. #define __glibcxx_check_subscript(_N) \
  264. _GLIBCXX_DEBUG_VERIFY(_N < this->size(), \
  265. _M_message(__gnu_debug::__msg_subscript_oob) \
  266. ._M_sequence(*this, "this") \
  267. ._M_integer(_N, #_N) \
  268. ._M_integer(this->size(), "size"))
  269. // Verify that the bucket _N is less than the container's buckets count.
  270. #define __glibcxx_check_bucket_index(_N) \
  271. _GLIBCXX_DEBUG_VERIFY(_N < this->bucket_count(), \
  272. _M_message(__gnu_debug::__msg_bucket_index_oob) \
  273. ._M_sequence(*this, "this") \
  274. ._M_integer(_N, #_N) \
  275. ._M_integer(this->bucket_count(), "size"))
  276. // Verify that the container is nonempty
  277. #define __glibcxx_check_nonempty() \
  278. _GLIBCXX_DEBUG_VERIFY(! this->empty(), \
  279. _M_message(__gnu_debug::__msg_empty) \
  280. ._M_sequence(*this, "this"))
  281. // Verify that a predicate is irreflexive
  282. #define __glibcxx_check_irreflexive(_First,_Last) \
  283. _GLIBCXX_DEBUG_VERIFY(_First == _Last || !(*_First < *_First), \
  284. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  285. ._M_iterator_value_type(_First, "< operator type"))
  286. #if __cplusplus >= 201103L
  287. # define __glibcxx_check_irreflexive2(_First,_Last) \
  288. _GLIBCXX_DEBUG_VERIFY(_First == _Last \
  289. || __gnu_debug::__is_irreflexive(_First), \
  290. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  291. ._M_iterator_value_type(_First, "< operator type"))
  292. #else
  293. # define __glibcxx_check_irreflexive2(_First,_Last)
  294. #endif
  295. #define __glibcxx_check_irreflexive_pred(_First,_Last,_Pred) \
  296. _GLIBCXX_DEBUG_VERIFY(_First == _Last || !_Pred(*_First, *_First), \
  297. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  298. ._M_instance(_Pred, "functor") \
  299. ._M_iterator_value_type(_First, "ordered type"))
  300. #if __cplusplus >= 201103L
  301. # define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred) \
  302. _GLIBCXX_DEBUG_VERIFY(_First == _Last \
  303. ||__gnu_debug::__is_irreflexive_pred(_First, _Pred), \
  304. _M_message(__gnu_debug::__msg_irreflexive_ordering) \
  305. ._M_instance(_Pred, "functor") \
  306. ._M_iterator_value_type(_First, "ordered type"))
  307. #else
  308. # define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred)
  309. #endif
  310. // Verify that the iterator range [_First, _Last) is sorted
  311. #define __glibcxx_check_sorted(_First,_Last) \
  312. __glibcxx_check_valid_range(_First,_Last); \
  313. __glibcxx_check_irreflexive(_First,_Last); \
  314. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
  315. __gnu_debug::__base(_First), \
  316. __gnu_debug::__base(_Last)), \
  317. _M_message(__gnu_debug::__msg_unsorted) \
  318. ._M_iterator(_First, #_First) \
  319. ._M_iterator(_Last, #_Last))
  320. /** Verify that the iterator range [_First, _Last) is sorted by the
  321. predicate _Pred. */
  322. #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \
  323. __glibcxx_check_valid_range(_First,_Last); \
  324. __glibcxx_check_irreflexive_pred(_First,_Last,_Pred); \
  325. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
  326. __gnu_debug::__base(_First), \
  327. __gnu_debug::__base(_Last), _Pred), \
  328. _M_message(__gnu_debug::__msg_unsorted_pred) \
  329. ._M_iterator(_First, #_First) \
  330. ._M_iterator(_Last, #_Last) \
  331. ._M_string(#_Pred))
  332. // Special variant for std::merge, std::includes, std::set_*
  333. #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \
  334. __glibcxx_check_valid_range(_First1,_Last1); \
  335. _GLIBCXX_DEBUG_VERIFY( \
  336. __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
  337. __gnu_debug::__base(_Last1), _First2),\
  338. _M_message(__gnu_debug::__msg_unsorted) \
  339. ._M_iterator(_First1, #_First1) \
  340. ._M_iterator(_Last1, #_Last1))
  341. // Likewise with a _Pred.
  342. #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
  343. __glibcxx_check_valid_range(_First1,_Last1); \
  344. _GLIBCXX_DEBUG_VERIFY( \
  345. __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
  346. __gnu_debug::__base(_Last1), \
  347. _First2, _Pred), \
  348. _M_message(__gnu_debug::__msg_unsorted_pred) \
  349. ._M_iterator(_First1, #_First1) \
  350. ._M_iterator(_Last1, #_Last1) \
  351. ._M_string(#_Pred))
  352. /** Verify that the iterator range [_First, _Last) is partitioned
  353. w.r.t. the value _Value. */
  354. #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \
  355. __glibcxx_check_valid_range(_First,_Last); \
  356. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
  357. __gnu_debug::__base(_First), \
  358. __gnu_debug::__base(_Last), _Value), \
  359. _M_message(__gnu_debug::__msg_unpartitioned) \
  360. ._M_iterator(_First, #_First) \
  361. ._M_iterator(_Last, #_Last) \
  362. ._M_string(#_Value))
  363. #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \
  364. __glibcxx_check_valid_range(_First,_Last); \
  365. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
  366. __gnu_debug::__base(_First), \
  367. __gnu_debug::__base(_Last), _Value), \
  368. _M_message(__gnu_debug::__msg_unpartitioned) \
  369. ._M_iterator(_First, #_First) \
  370. ._M_iterator(_Last, #_Last) \
  371. ._M_string(#_Value))
  372. /** Verify that the iterator range [_First, _Last) is partitioned
  373. w.r.t. the value _Value and predicate _Pred. */
  374. #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
  375. __glibcxx_check_valid_range(_First,_Last); \
  376. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
  377. __gnu_debug::__base(_First), \
  378. __gnu_debug::__base(_Last), _Value, _Pred), \
  379. _M_message(__gnu_debug::__msg_unpartitioned_pred) \
  380. ._M_iterator(_First, #_First) \
  381. ._M_iterator(_Last, #_Last) \
  382. ._M_string(#_Pred) \
  383. ._M_string(#_Value))
  384. /** Verify that the iterator range [_First, _Last) is partitioned
  385. w.r.t. the value _Value and predicate _Pred. */
  386. #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
  387. __glibcxx_check_valid_range(_First,_Last); \
  388. _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
  389. __gnu_debug::__base(_First), \
  390. __gnu_debug::__base(_Last), _Value, _Pred), \
  391. _M_message(__gnu_debug::__msg_unpartitioned_pred) \
  392. ._M_iterator(_First, #_First) \
  393. ._M_iterator(_Last, #_Last) \
  394. ._M_string(#_Pred) \
  395. ._M_string(#_Value))
  396. // Verify that the iterator range [_First, _Last) is a heap
  397. #define __glibcxx_check_heap(_First,_Last) \
  398. _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
  399. __gnu_debug::__base(_Last)), \
  400. _M_message(__gnu_debug::__msg_not_heap) \
  401. ._M_iterator(_First, #_First) \
  402. ._M_iterator(_Last, #_Last))
  403. /** Verify that the iterator range [_First, _Last) is a heap
  404. w.r.t. the predicate _Pred. */
  405. #define __glibcxx_check_heap_pred(_First,_Last,_Pred) \
  406. _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
  407. __gnu_debug::__base(_Last), \
  408. _Pred), \
  409. _M_message(__gnu_debug::__msg_not_heap_pred) \
  410. ._M_iterator(_First, #_First) \
  411. ._M_iterator(_Last, #_Last) \
  412. ._M_string(#_Pred))
  413. // Verify that load factor is positive
  414. #define __glibcxx_check_max_load_factor(_F) \
  415. _GLIBCXX_DEBUG_VERIFY(_F > 0.0f, \
  416. _M_message(__gnu_debug::__msg_valid_load_factor) \
  417. ._M_sequence(*this, "this"))
  418. #define __glibcxx_check_equal_allocs(_This, _Other) \
  419. _GLIBCXX_DEBUG_VERIFY(_This.get_allocator() == _Other.get_allocator(), \
  420. _M_message(__gnu_debug::__msg_equal_allocs) \
  421. ._M_sequence(_This, "this"))
  422. #define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_PEDASSERT(_String != 0)
  423. #define __glibcxx_check_string_len(_String,_Len) \
  424. _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)
  425. #endif