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))
60 #define __glibcxx_check_non_empty_range(_First,_Last) \
61 _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
62 _M_message(__gnu_debug::__msg_non_empty_range) \
63 ._M_iterator(_First, #_First) \
64 ._M_iterator(_Last, #_Last))
73 #define __glibcxx_check_insert(_Position) \
74 _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \
75 _M_message(__gnu_debug::__msg_insert_singular) \
76 ._M_sequence(*this, "this") \
77 ._M_iterator(_Position, #_Position)); \
78 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
79 _M_message(__gnu_debug::__msg_insert_different) \
80 ._M_sequence(*this, "this") \
81 ._M_iterator(_Position, #_Position))
90 #define __glibcxx_check_insert_after(_Position) \
91 __glibcxx_check_insert(_Position); \
92 _GLIBCXX_DEBUG_VERIFY(!_Position._M_is_end(), \
93 _M_message(__gnu_debug::__msg_insert_after_end) \
94 ._M_sequence(*this, "this") \
95 ._M_iterator(_Position, #_Position))
106 #define __glibcxx_check_insert_range(_Position,_First,_Last) \
107 __glibcxx_check_valid_range(_First,_Last); \
108 __glibcxx_check_insert(_Position); \
109 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First),\
110 _M_message(__gnu_debug::__msg_insert_range_from_self)\
111 ._M_iterator(_First, #_First) \
112 ._M_iterator(_Last, #_Last) \
113 ._M_sequence(*this, "this"))
128 #define __glibcxx_check_insert_range_after(_Position,_First,_Last) \
129 __glibcxx_check_valid_range(_First,_Last); \
130 __glibcxx_check_insert_after(_Position); \
131 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First),\
132 _M_message(__gnu_debug::__msg_insert_range_from_self)\
133 ._M_iterator(_First, #_First) \
134 ._M_iterator(_Last, #_Last) \
135 ._M_sequence(*this, "this"))
141 #define __glibcxx_check_erase(_Position) \
142 _GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \
143 _M_message(__gnu_debug::__msg_erase_bad) \
144 ._M_sequence(*this, "this") \
145 ._M_iterator(_Position, #_Position)); \
146 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
147 _M_message(__gnu_debug::__msg_erase_different) \
148 ._M_sequence(*this, "this") \
149 ._M_iterator(_Position, #_Position))
155 #define __glibcxx_check_erase_after(_Position) \
156 _GLIBCXX_DEBUG_VERIFY(_Position._M_before_dereferenceable(), \
157 _M_message(__gnu_debug::__msg_erase_after_bad) \
158 ._M_sequence(*this, "this") \
159 ._M_iterator(_Position, #_Position)); \
160 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
161 _M_message(__gnu_debug::__msg_erase_different) \
162 ._M_sequence(*this, "this") \
163 ._M_iterator(_Position, #_Position))
169 #define __glibcxx_check_erase_range(_First,_Last) \
170 __glibcxx_check_valid_range(_First,_Last); \
171 _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
172 _M_message(__gnu_debug::__msg_erase_different) \
173 ._M_sequence(*this, "this") \
174 ._M_iterator(_First, #_First) \
175 ._M_iterator(_Last, #_Last))
181 #define __glibcxx_check_erase_range_after(_First,_Last) \
182 _GLIBCXX_DEBUG_VERIFY(_First._M_can_compare(_Last), \
183 _M_message(__gnu_debug::__msg_erase_different) \
184 ._M_sequence(*this, "this") \
185 ._M_iterator(_First, #_First) \
186 ._M_iterator(_Last, #_Last)); \
187 _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
188 _M_message(__gnu_debug::__msg_erase_different) \
189 ._M_sequence(*this, "this") \
190 ._M_iterator(_First, #_First)); \
191 _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
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(_First._M_incrementable(), \
197 _M_message(__gnu_debug::__msg_valid_range2) \
198 ._M_sequence(*this, "this") \
199 ._M_iterator(_First, #_First) \
200 ._M_iterator(_Last, #_Last)); \
201 _GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(), \
202 _M_message(__gnu_debug::__msg_valid_range2) \
203 ._M_sequence(*this, "this") \
204 ._M_iterator(_First, #_First) \
205 ._M_iterator(_Last, #_Last)) \
208 #define __glibcxx_check_subscript(_N) \
209 _GLIBCXX_DEBUG_VERIFY(_N < this->size(), \
210 _M_message(__gnu_debug::__msg_subscript_oob) \
211 ._M_sequence(*this, "this") \
212 ._M_integer(_N, #_N) \
213 ._M_integer(this->size(), "size"))
216 #define __glibcxx_check_bucket_index(_N) \
217 _GLIBCXX_DEBUG_VERIFY(_N < this->bucket_count(), \
218 _M_message(__gnu_debug::__msg_bucket_index_oob) \
219 ._M_sequence(*this, "this") \
220 ._M_integer(_N, #_N) \
221 ._M_integer(this->bucket_count(), "size"))
224 #define __glibcxx_check_nonempty() \
225 _GLIBCXX_DEBUG_VERIFY(! this->empty(), \
226 _M_message(__gnu_debug::__msg_empty) \
227 ._M_sequence(*this, "this"))
230 #define __glibcxx_check_sorted(_First,_Last) \
231 __glibcxx_check_valid_range(_First,_Last); \
232 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
233 __gnu_debug::__base(_First), \
234 __gnu_debug::__base(_Last)), \
235 _M_message(__gnu_debug::__msg_unsorted) \
236 ._M_iterator(_First, #_First) \
237 ._M_iterator(_Last, #_Last))
241 #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \
242 __glibcxx_check_valid_range(_First,_Last); \
243 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
244 __gnu_debug::__base(_First), \
245 __gnu_debug::__base(_Last), _Pred), \
246 _M_message(__gnu_debug::__msg_unsorted_pred) \
247 ._M_iterator(_First, #_First) \
248 ._M_iterator(_Last, #_Last) \
252 #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \
253 __glibcxx_check_valid_range(_First1,_Last1); \
254 _GLIBCXX_DEBUG_VERIFY( \
255 __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
256 __gnu_debug::__base(_Last1), _First2),\
257 _M_message(__gnu_debug::__msg_unsorted) \
258 ._M_iterator(_First1, #_First1) \
259 ._M_iterator(_Last1, #_Last1))
262 #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
263 __glibcxx_check_valid_range(_First1,_Last1); \
264 _GLIBCXX_DEBUG_VERIFY( \
265 __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
266 __gnu_debug::__base(_Last1), \
268 _M_message(__gnu_debug::__msg_unsorted_pred) \
269 ._M_iterator(_First1, #_First1) \
270 ._M_iterator(_Last1, #_Last1) \
275 #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \
276 __glibcxx_check_valid_range(_First,_Last); \
277 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
278 __gnu_debug::__base(_First), \
279 __gnu_debug::__base(_Last), _Value), \
280 _M_message(__gnu_debug::__msg_unpartitioned) \
281 ._M_iterator(_First, #_First) \
282 ._M_iterator(_Last, #_Last) \
285 #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \
286 __glibcxx_check_valid_range(_First,_Last); \
287 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
288 __gnu_debug::__base(_First), \
289 __gnu_debug::__base(_Last), _Value), \
290 _M_message(__gnu_debug::__msg_unpartitioned) \
291 ._M_iterator(_First, #_First) \
292 ._M_iterator(_Last, #_Last) \
297 #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
298 __glibcxx_check_valid_range(_First,_Last); \
299 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
300 __gnu_debug::__base(_First), \
301 __gnu_debug::__base(_Last), _Value, _Pred), \
302 _M_message(__gnu_debug::__msg_unpartitioned_pred) \
303 ._M_iterator(_First, #_First) \
304 ._M_iterator(_Last, #_Last) \
310 #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
311 __glibcxx_check_valid_range(_First,_Last); \
312 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
313 __gnu_debug::__base(_First), \
314 __gnu_debug::__base(_Last), _Value, _Pred), \
315 _M_message(__gnu_debug::__msg_unpartitioned_pred) \
316 ._M_iterator(_First, #_First) \
317 ._M_iterator(_Last, #_Last) \
322 #define __glibcxx_check_heap(_First,_Last) \
323 _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
324 __gnu_debug::__base(_Last)), \
325 _M_message(__gnu_debug::__msg_not_heap) \
326 ._M_iterator(_First, #_First) \
327 ._M_iterator(_Last, #_Last))
331 #define __glibcxx_check_heap_pred(_First,_Last,_Pred) \
332 _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
333 __gnu_debug::__base(_Last), \
335 _M_message(__gnu_debug::__msg_not_heap_pred) \
336 ._M_iterator(_First, #_First) \
337 ._M_iterator(_Last, #_Last) \
341 #define __glibcxx_check_self_move_assign(_Other) \
342 _GLIBCXX_DEBUG_VERIFY(this != &_Other, \
343 _M_message(__gnu_debug::__msg_self_move_assign) \
344 ._M_sequence(*this, "this"))
347 #define __glibcxx_check_max_load_factor(_F) \
348 _GLIBCXX_DEBUG_VERIFY(_F > 0.0f, \
349 _M_message(__gnu_debug::__msg_valid_load_factor) \
350 ._M_sequence(*this, "this"))
352 #define __glibcxx_check_equal_allocs(_Other) \
353 _GLIBCXX_DEBUG_VERIFY(this->get_allocator() == _Other.get_allocator(), \
354 _M_message(__gnu_debug::__msg_equal_allocs) \
355 ._M_sequence(*this, "this"))
357 #ifdef _GLIBCXX_DEBUG_PEDANTIC
358 # define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0)
359 # define __glibcxx_check_string_len(_String,_Len) \
360 _GLIBCXX_DEBUG_ASSERT(_String != 0 || _Len == 0)
362 # define __glibcxx_check_string(_String)
363 # define __glibcxx_check_string_len(_String,_Len)