Go to the documentation of this file.
30 #ifndef _GLIBCXX_DEBUG_MACROS_H
31 #define _GLIBCXX_DEBUG_MACROS_H 1
42 #define _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,_File,_Line) \
46 __gnu_debug::_Error_formatter::_M_at(_File, _Line) \
47 ._ErrorMessage._M_error(); \
50 #define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage) \
51 _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,__FILE__,__LINE__)
54 #define __glibcxx_check_valid_range(_First,_Last) \
55 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \
56 _M_message(__gnu_debug::__msg_valid_range) \
57 ._M_iterator(_First, #_First) \
58 ._M_iterator(_Last, #_Last))
61 #define __glibcxx_check_non_empty_range(_First,_Last) \
62 _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
63 _M_message(__gnu_debug::__msg_non_empty_range) \
64 ._M_iterator(_First, #_First) \
65 ._M_iterator(_Last, #_Last))
74 #define __glibcxx_check_insert(_Position) \
75 _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \
76 _M_message(__gnu_debug::__msg_insert_singular) \
77 ._M_sequence(*this, "this") \
78 ._M_iterator(_Position, #_Position)); \
79 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
80 _M_message(__gnu_debug::__msg_insert_different) \
81 ._M_sequence(*this, "this") \
82 ._M_iterator(_Position, #_Position))
91 #define __glibcxx_check_insert_after(_Position) \
92 __glibcxx_check_insert(_Position); \
93 _GLIBCXX_DEBUG_VERIFY(!_Position._M_is_end(), \
94 _M_message(__gnu_debug::__msg_insert_after_end) \
95 ._M_sequence(*this, "this") \
96 ._M_iterator(_Position, #_Position))
111 #define __glibcxx_check_insert_range(_Position,_First,_Last) \
112 __glibcxx_check_valid_range(_First,_Last); \
113 __glibcxx_check_insert(_Position)
128 #define __glibcxx_check_insert_range_after(_Position,_First,_Last) \
129 __glibcxx_check_valid_range(_First,_Last); \
130 __glibcxx_check_insert_after(_Position)
136 #define __glibcxx_check_erase(_Position) \
137 _GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \
138 _M_message(__gnu_debug::__msg_erase_bad) \
139 ._M_sequence(*this, "this") \
140 ._M_iterator(_Position, #_Position)); \
141 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
142 _M_message(__gnu_debug::__msg_erase_different) \
143 ._M_sequence(*this, "this") \
144 ._M_iterator(_Position, #_Position))
150 #define __glibcxx_check_erase_after(_Position) \
151 _GLIBCXX_DEBUG_VERIFY(_Position._M_before_dereferenceable(), \
152 _M_message(__gnu_debug::__msg_erase_after_bad) \
153 ._M_sequence(*this, "this") \
154 ._M_iterator(_Position, #_Position)); \
155 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
156 _M_message(__gnu_debug::__msg_erase_different) \
157 ._M_sequence(*this, "this") \
158 ._M_iterator(_Position, #_Position))
164 #define __glibcxx_check_erase_range(_First,_Last) \
165 __glibcxx_check_valid_range(_First,_Last); \
166 _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
167 _M_message(__gnu_debug::__msg_erase_different) \
168 ._M_sequence(*this, "this") \
169 ._M_iterator(_First, #_First) \
170 ._M_iterator(_Last, #_Last))
176 #define __glibcxx_check_erase_range_after(_First,_Last) \
177 _GLIBCXX_DEBUG_VERIFY(_First._M_can_compare(_Last), \
178 _M_message(__gnu_debug::__msg_erase_different) \
179 ._M_sequence(*this, "this") \
180 ._M_iterator(_First, #_First) \
181 ._M_iterator(_Last, #_Last)); \
182 _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
183 _M_message(__gnu_debug::__msg_erase_different) \
184 ._M_sequence(*this, "this") \
185 ._M_iterator(_First, #_First)); \
186 _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
187 _M_message(__gnu_debug::__msg_valid_range2) \
188 ._M_sequence(*this, "this") \
189 ._M_iterator(_First, #_First) \
190 ._M_iterator(_Last, #_Last)); \
191 _GLIBCXX_DEBUG_VERIFY(_First._M_incrementable(), \
192 _M_message(__gnu_debug::__msg_valid_range2) \
193 ._M_sequence(*this, "this") \
194 ._M_iterator(_First, #_First) \
195 ._M_iterator(_Last, #_Last)); \
196 _GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(), \
197 _M_message(__gnu_debug::__msg_valid_range2) \
198 ._M_sequence(*this, "this") \
199 ._M_iterator(_First, #_First) \
200 ._M_iterator(_Last, #_Last)) \
203 #define __glibcxx_check_subscript(_N) \
204 _GLIBCXX_DEBUG_VERIFY(_N < this->size(), \
205 _M_message(__gnu_debug::__msg_subscript_oob) \
206 ._M_sequence(*this, "this") \
207 ._M_integer(_N, #_N) \
208 ._M_integer(this->size(), "size"))
211 #define __glibcxx_check_nonempty() \
212 _GLIBCXX_DEBUG_VERIFY(! this->empty(), \
213 _M_message(__gnu_debug::__msg_empty) \
214 ._M_sequence(*this, "this"))
217 #define __glibcxx_check_sorted(_First,_Last) \
218 __glibcxx_check_valid_range(_First,_Last); \
219 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last), \
220 _M_message(__gnu_debug::__msg_unsorted) \
221 ._M_iterator(_First, #_First) \
222 ._M_iterator(_Last, #_Last))
226 #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \
227 __glibcxx_check_valid_range(_First,_Last); \
228 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \
229 _M_message(__gnu_debug::__msg_unsorted_pred) \
230 ._M_iterator(_First, #_First) \
231 ._M_iterator(_Last, #_Last) \
235 #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \
236 __glibcxx_check_valid_range(_First1,_Last1); \
237 _GLIBCXX_DEBUG_VERIFY( \
238 __gnu_debug::__check_sorted_set(_First1, _Last1, _First2), \
239 _M_message(__gnu_debug::__msg_unsorted) \
240 ._M_iterator(_First1, #_First1) \
241 ._M_iterator(_Last1, #_Last1))
244 #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
245 __glibcxx_check_valid_range(_First1,_Last1); \
246 _GLIBCXX_DEBUG_VERIFY( \
247 __gnu_debug::__check_sorted_set(_First1, _Last1, _First2, _Pred), \
248 _M_message(__gnu_debug::__msg_unsorted_pred) \
249 ._M_iterator(_First1, #_First1) \
250 ._M_iterator(_Last1, #_Last1) \
255 #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \
256 __glibcxx_check_valid_range(_First,_Last); \
257 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
259 _M_message(__gnu_debug::__msg_unpartitioned) \
260 ._M_iterator(_First, #_First) \
261 ._M_iterator(_Last, #_Last) \
264 #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \
265 __glibcxx_check_valid_range(_First,_Last); \
266 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
268 _M_message(__gnu_debug::__msg_unpartitioned) \
269 ._M_iterator(_First, #_First) \
270 ._M_iterator(_Last, #_Last) \
275 #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
276 __glibcxx_check_valid_range(_First,_Last); \
277 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
279 _M_message(__gnu_debug::__msg_unpartitioned_pred) \
280 ._M_iterator(_First, #_First) \
281 ._M_iterator(_Last, #_Last) \
287 #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
288 __glibcxx_check_valid_range(_First,_Last); \
289 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
291 _M_message(__gnu_debug::__msg_unpartitioned_pred) \
292 ._M_iterator(_First, #_First) \
293 ._M_iterator(_Last, #_Last) \
298 #define __glibcxx_check_heap(_First,_Last) \
299 _GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last), \
300 _M_message(__gnu_debug::__msg_not_heap) \
301 ._M_iterator(_First, #_First) \
302 ._M_iterator(_Last, #_Last))
306 #define __glibcxx_check_heap_pred(_First,_Last,_Pred) \
307 _GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last, _Pred), \
308 _M_message(__gnu_debug::__msg_not_heap_pred) \
309 ._M_iterator(_First, #_First) \
310 ._M_iterator(_Last, #_Last) \
313 #ifdef _GLIBCXX_DEBUG_PEDANTIC
314 # define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0)
315 # define __glibcxx_check_string_len(_String,_Len) \
316 _GLIBCXX_DEBUG_ASSERT(_String != 0 || _Len == 0)
318 # define __glibcxx_check_string(_String)
319 # define __glibcxx_check_string_len(_String,_Len)