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