Go to the documentation of this file. 29 #ifndef _GLIBCXX_DEBUG_MACROS_H 30 #define _GLIBCXX_DEBUG_MACROS_H 1 41 #define _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,_File,_Line) \ 45 __gnu_debug::_Error_formatter::_M_at(_File, _Line) \ 46 ._ErrorMessage._M_error(); \ 49 #define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \ 50 _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,__FILE__,__LINE__) 53 #define __glibcxx_check_valid_range(_First,_Last) \ 54 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \ 55 _M_message(__gnu_debug::__msg_valid_range) \ 56 ._M_iterator(_First, #_First) \ 57 ._M_iterator(_Last, #_Last)) 59 #define __glibcxx_check_valid_range2(_First,_Last,_Dist) \ 60 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last, _Dist), \ 61 _M_message(__gnu_debug::__msg_valid_range) \ 62 ._M_iterator(_First, #_First) \ 63 ._M_iterator(_Last, #_Last)) 66 #define __glibcxx_check_non_empty_range(_First,_Last) \ 67 _GLIBCXX_DEBUG_VERIFY(_First != _Last, \ 68 _M_message(__gnu_debug::__msg_non_empty_range) \ 69 ._M_iterator(_First, #_First) \ 70 ._M_iterator(_Last, #_Last)) 79 #define __glibcxx_check_insert(_Position) \ 80 _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ 81 _M_message(__gnu_debug::__msg_insert_singular) \ 82 ._M_sequence(*this, "this") \ 83 ._M_iterator(_Position, #_Position)); \ 84 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ 85 _M_message(__gnu_debug::__msg_insert_different) \ 86 ._M_sequence(*this, "this") \ 87 ._M_iterator(_Position, #_Position)) 96 #define __glibcxx_check_insert_after(_Position) \ 97 __glibcxx_check_insert(_Position); \ 98 _GLIBCXX_DEBUG_VERIFY(!_Position._M_is_end(), \ 99 _M_message(__gnu_debug::__msg_insert_after_end) \ 100 ._M_sequence(*this, "this") \ 101 ._M_iterator(_Position, #_Position)) 113 #define __glibcxx_check_insert_range(_Position,_First,_Last,_Dist) \ 114 __glibcxx_check_valid_range2(_First,_Last,_Dist); \ 115 __glibcxx_check_insert(_Position); \ 116 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\ 117 _M_message(__gnu_debug::__msg_insert_range_from_self)\ 118 ._M_iterator(_First, #_First) \ 119 ._M_iterator(_Last, #_Last) \ 120 ._M_sequence(*this, "this")) 132 #define __glibcxx_check_insert_range_after(_Position,_First,_Last,_Dist)\ 133 __glibcxx_check_valid_range2(_First,_Last,_Dist); \ 134 __glibcxx_check_insert_after(_Position); \ 135 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\ 136 _M_message(__gnu_debug::__msg_insert_range_from_self)\ 137 ._M_iterator(_First, #_First) \ 138 ._M_iterator(_Last, #_Last) \ 139 ._M_sequence(*this, "this")) 145 #define __glibcxx_check_erase(_Position) \ 146 _GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \ 147 _M_message(__gnu_debug::__msg_erase_bad) \ 148 ._M_sequence(*this, "this") \ 149 ._M_iterator(_Position, #_Position)); \ 150 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ 151 _M_message(__gnu_debug::__msg_erase_different) \ 152 ._M_sequence(*this, "this") \ 153 ._M_iterator(_Position, #_Position)) 159 #define __glibcxx_check_erase_after(_Position) \ 160 _GLIBCXX_DEBUG_VERIFY(_Position._M_before_dereferenceable(), \ 161 _M_message(__gnu_debug::__msg_erase_after_bad) \ 162 ._M_sequence(*this, "this") \ 163 ._M_iterator(_Position, #_Position)); \ 164 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ 165 _M_message(__gnu_debug::__msg_erase_different) \ 166 ._M_sequence(*this, "this") \ 167 ._M_iterator(_Position, #_Position)) 173 #define __glibcxx_check_erase_range(_First,_Last) \ 174 __glibcxx_check_valid_range(_First,_Last); \ 175 _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \ 176 _M_message(__gnu_debug::__msg_erase_different) \ 177 ._M_sequence(*this, "this") \ 178 ._M_iterator(_First, #_First) \ 179 ._M_iterator(_Last, #_Last)) 185 #define __glibcxx_check_erase_range_after(_First,_Last) \ 186 _GLIBCXX_DEBUG_VERIFY(_First._M_can_compare(_Last), \ 187 _M_message(__gnu_debug::__msg_erase_different) \ 188 ._M_sequence(*this, "this") \ 189 ._M_iterator(_First, #_First) \ 190 ._M_iterator(_Last, #_Last)); \ 191 _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \ 192 _M_message(__gnu_debug::__msg_erase_different) \ 193 ._M_sequence(*this, "this") \ 194 ._M_iterator(_First, #_First)); \ 195 _GLIBCXX_DEBUG_VERIFY(_First != _Last, \ 196 _M_message(__gnu_debug::__msg_valid_range2) \ 197 ._M_sequence(*this, "this") \ 198 ._M_iterator(_First, #_First) \ 199 ._M_iterator(_Last, #_Last)); \ 200 _GLIBCXX_DEBUG_VERIFY(_First._M_incrementable(), \ 201 _M_message(__gnu_debug::__msg_valid_range2) \ 202 ._M_sequence(*this, "this") \ 203 ._M_iterator(_First, #_First) \ 204 ._M_iterator(_Last, #_Last)); \ 205 _GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(), \ 206 _M_message(__gnu_debug::__msg_valid_range2) \ 207 ._M_sequence(*this, "this") \ 208 ._M_iterator(_First, #_First) \ 209 ._M_iterator(_Last, #_Last)) \ 212 #define __glibcxx_check_subscript(_N) \ 213 _GLIBCXX_DEBUG_VERIFY(_N < this->size(), \ 214 _M_message(__gnu_debug::__msg_subscript_oob) \ 215 ._M_sequence(*this, "this") \ 216 ._M_integer(_N, #_N) \ 217 ._M_integer(this->size(), "size")) 220 #define __glibcxx_check_bucket_index(_N) \ 221 _GLIBCXX_DEBUG_VERIFY(_N < this->bucket_count(), \ 222 _M_message(__gnu_debug::__msg_bucket_index_oob) \ 223 ._M_sequence(*this, "this") \ 224 ._M_integer(_N, #_N) \ 225 ._M_integer(this->bucket_count(), "size")) 228 #define __glibcxx_check_nonempty() \ 229 _GLIBCXX_DEBUG_VERIFY(! this->empty(), \ 230 _M_message(__gnu_debug::__msg_empty) \ 231 ._M_sequence(*this, "this")) 234 #define __glibcxx_check_sorted(_First,_Last) \ 235 __glibcxx_check_valid_range(_First,_Last); \ 236 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \ 237 __gnu_debug::__base(_First), \ 238 __gnu_debug::__base(_Last)), \ 239 _M_message(__gnu_debug::__msg_unsorted) \ 240 ._M_iterator(_First, #_First) \ 241 ._M_iterator(_Last, #_Last)) 245 #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \ 246 __glibcxx_check_valid_range(_First,_Last); \ 247 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \ 248 __gnu_debug::__base(_First), \ 249 __gnu_debug::__base(_Last), _Pred), \ 250 _M_message(__gnu_debug::__msg_unsorted_pred) \ 251 ._M_iterator(_First, #_First) \ 252 ._M_iterator(_Last, #_Last) \ 256 #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \ 257 __glibcxx_check_valid_range(_First1,_Last1); \ 258 _GLIBCXX_DEBUG_VERIFY( \ 259 __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \ 260 __gnu_debug::__base(_Last1), _First2),\ 261 _M_message(__gnu_debug::__msg_unsorted) \ 262 ._M_iterator(_First1, #_First1) \ 263 ._M_iterator(_Last1, #_Last1)) 266 #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \ 267 __glibcxx_check_valid_range(_First1,_Last1); \ 268 _GLIBCXX_DEBUG_VERIFY( \ 269 __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \ 270 __gnu_debug::__base(_Last1), \ 272 _M_message(__gnu_debug::__msg_unsorted_pred) \ 273 ._M_iterator(_First1, #_First1) \ 274 ._M_iterator(_Last1, #_Last1) \ 279 #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \ 280 __glibcxx_check_valid_range(_First,_Last); \ 281 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \ 282 __gnu_debug::__base(_First), \ 283 __gnu_debug::__base(_Last), _Value), \ 284 _M_message(__gnu_debug::__msg_unpartitioned) \ 285 ._M_iterator(_First, #_First) \ 286 ._M_iterator(_Last, #_Last) \ 289 #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \ 290 __glibcxx_check_valid_range(_First,_Last); \ 291 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \ 292 __gnu_debug::__base(_First), \ 293 __gnu_debug::__base(_Last), _Value), \ 294 _M_message(__gnu_debug::__msg_unpartitioned) \ 295 ._M_iterator(_First, #_First) \ 296 ._M_iterator(_Last, #_Last) \ 301 #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \ 302 __glibcxx_check_valid_range(_First,_Last); \ 303 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \ 304 __gnu_debug::__base(_First), \ 305 __gnu_debug::__base(_Last), _Value, _Pred), \ 306 _M_message(__gnu_debug::__msg_unpartitioned_pred) \ 307 ._M_iterator(_First, #_First) \ 308 ._M_iterator(_Last, #_Last) \ 314 #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \ 315 __glibcxx_check_valid_range(_First,_Last); \ 316 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \ 317 __gnu_debug::__base(_First), \ 318 __gnu_debug::__base(_Last), _Value, _Pred), \ 319 _M_message(__gnu_debug::__msg_unpartitioned_pred) \ 320 ._M_iterator(_First, #_First) \ 321 ._M_iterator(_Last, #_Last) \ 326 #define __glibcxx_check_heap(_First,_Last) \ 327 _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \ 328 __gnu_debug::__base(_Last)), \ 329 _M_message(__gnu_debug::__msg_not_heap) \ 330 ._M_iterator(_First, #_First) \ 331 ._M_iterator(_Last, #_Last)) 335 #define __glibcxx_check_heap_pred(_First,_Last,_Pred) \ 336 _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \ 337 __gnu_debug::__base(_Last), \ 339 _M_message(__gnu_debug::__msg_not_heap_pred) \ 340 ._M_iterator(_First, #_First) \ 341 ._M_iterator(_Last, #_Last) \ 345 #define __glibcxx_check_self_move_assign(_Other) \ 346 _GLIBCXX_DEBUG_VERIFY(this != &_Other, \ 347 _M_message(__gnu_debug::__msg_self_move_assign) \ 348 ._M_sequence(*this, "this")) 351 #define __glibcxx_check_max_load_factor(_F) \ 352 _GLIBCXX_DEBUG_VERIFY(_F > 0.0f, \ 353 _M_message(__gnu_debug::__msg_valid_load_factor) \ 354 ._M_sequence(*this, "this")) 356 #define __glibcxx_check_equal_allocs(_This, _Other) \ 357 _GLIBCXX_DEBUG_VERIFY(_This.get_allocator() == _Other.get_allocator(), \ 358 _M_message(__gnu_debug::__msg_equal_allocs) \ 359 ._M_sequence(_This, "this")) 361 #define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_PEDASSERT(_String != 0) 362 #define __glibcxx_check_string_len(_String,_Len) \ 363 _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0) 366 #define __glibcxx_check_irreflexive(_First,_Last) \ 367 _GLIBCXX_DEBUG_VERIFY(_First == _Last || !(*_First < *_First), \ 368 _M_message(__gnu_debug::__msg_irreflexive_ordering) \ 369 ._M_iterator_value_type(_First, "< operator type")) 371 #if __cplusplus >= 201103L 372 # define __glibcxx_check_irreflexive2(_First,_Last) \ 373 _GLIBCXX_DEBUG_VERIFY(_First == _Last \ 374 || __gnu_debug::__is_irreflexive(_First), \ 375 _M_message(__gnu_debug::__msg_irreflexive_ordering) \ 376 ._M_iterator_value_type(_First, "< operator type")) 378 # define __glibcxx_check_irreflexive2(_First,_Last) 381 #define __glibcxx_check_irreflexive_pred(_First,_Last,_Pred) \ 382 _GLIBCXX_DEBUG_VERIFY(_First == _Last || !_Pred(*_First, *_First), \ 383 _M_message(__gnu_debug::__msg_irreflexive_ordering) \ 384 ._M_instance(_Pred, "functor") \ 385 ._M_iterator_value_type(_First, "ordered type")) 387 #if __cplusplus >= 201103L 388 # define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred) \ 389 _GLIBCXX_DEBUG_VERIFY(_First == _Last \ 390 ||__gnu_debug::__is_irreflexive_pred(_First, _Pred), \ 391 _M_message(__gnu_debug::__msg_irreflexive_ordering) \ 392 ._M_instance(_Pred, "functor") \ 393 ._M_iterator_value_type(_First, "ordered type")) 395 # define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred)