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