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))
107 #define __glibcxx_check_insert_range(_Position,_First,_Last) \
108 __glibcxx_check_valid_range(_First,_Last); \
109 __glibcxx_check_insert(_Position); \
110 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
111 _M_message(__gnu_debug::__msg_insert_range_from_self)\
112 ._M_iterator(_First, #_First) \
113 ._M_iterator(_Last, #_Last) \
114 ._M_sequence(*this, "this"))
126 #define __glibcxx_check_insert_range_after(_Position,_First,_Last) \
127 __glibcxx_check_valid_range(_First,_Last); \
128 __glibcxx_check_insert_after(_Position); \
129 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
130 _M_message(__gnu_debug::__msg_insert_range_from_self)\
131 ._M_iterator(_First, #_First) \
132 ._M_iterator(_Last, #_Last) \
133 ._M_sequence(*this, "this"))
139 #define __glibcxx_check_erase(_Position) \
140 _GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \
141 _M_message(__gnu_debug::__msg_erase_bad) \
142 ._M_sequence(*this, "this") \
143 ._M_iterator(_Position, #_Position)); \
144 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
145 _M_message(__gnu_debug::__msg_erase_different) \
146 ._M_sequence(*this, "this") \
147 ._M_iterator(_Position, #_Position))
153 #define __glibcxx_check_erase_after(_Position) \
154 _GLIBCXX_DEBUG_VERIFY(_Position._M_before_dereferenceable(), \
155 _M_message(__gnu_debug::__msg_erase_after_bad) \
156 ._M_sequence(*this, "this") \
157 ._M_iterator(_Position, #_Position)); \
158 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
159 _M_message(__gnu_debug::__msg_erase_different) \
160 ._M_sequence(*this, "this") \
161 ._M_iterator(_Position, #_Position))
167 #define __glibcxx_check_erase_range(_First,_Last) \
168 __glibcxx_check_valid_range(_First,_Last); \
169 _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
170 _M_message(__gnu_debug::__msg_erase_different) \
171 ._M_sequence(*this, "this") \
172 ._M_iterator(_First, #_First) \
173 ._M_iterator(_Last, #_Last))
179 #define __glibcxx_check_erase_range_after(_First,_Last) \
180 _GLIBCXX_DEBUG_VERIFY(_First._M_can_compare(_Last), \
181 _M_message(__gnu_debug::__msg_erase_different) \
182 ._M_sequence(*this, "this") \
183 ._M_iterator(_First, #_First) \
184 ._M_iterator(_Last, #_Last)); \
185 _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
186 _M_message(__gnu_debug::__msg_erase_different) \
187 ._M_sequence(*this, "this") \
188 ._M_iterator(_First, #_First)); \
189 _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
190 _M_message(__gnu_debug::__msg_valid_range2) \
191 ._M_sequence(*this, "this") \
192 ._M_iterator(_First, #_First) \
193 ._M_iterator(_Last, #_Last)); \
194 _GLIBCXX_DEBUG_VERIFY(_First._M_incrementable(), \
195 _M_message(__gnu_debug::__msg_valid_range2) \
196 ._M_sequence(*this, "this") \
197 ._M_iterator(_First, #_First) \
198 ._M_iterator(_Last, #_Last)); \
199 _GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(), \
200 _M_message(__gnu_debug::__msg_valid_range2) \
201 ._M_sequence(*this, "this") \
202 ._M_iterator(_First, #_First) \
203 ._M_iterator(_Last, #_Last)) \
206 #define __glibcxx_check_subscript(_N) \
207 _GLIBCXX_DEBUG_VERIFY(_N < this->size(), \
208 _M_message(__gnu_debug::__msg_subscript_oob) \
209 ._M_sequence(*this, "this") \
210 ._M_integer(_N, #_N) \
211 ._M_integer(this->size(), "size"))
214 #define __glibcxx_check_bucket_index(_N) \
215 _GLIBCXX_DEBUG_VERIFY(_N < this->bucket_count(), \
216 _M_message(__gnu_debug::__msg_bucket_index_oob) \
217 ._M_sequence(*this, "this") \
218 ._M_integer(_N, #_N) \
219 ._M_integer(this->bucket_count(), "size"))
222 #define __glibcxx_check_nonempty() \
223 _GLIBCXX_DEBUG_VERIFY(! this->empty(), \
224 _M_message(__gnu_debug::__msg_empty) \
225 ._M_sequence(*this, "this"))
228 #define __glibcxx_check_sorted(_First,_Last) \
229 __glibcxx_check_valid_range(_First,_Last); \
230 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
231 __gnu_debug::__base(_First), \
232 __gnu_debug::__base(_Last)), \
233 _M_message(__gnu_debug::__msg_unsorted) \
234 ._M_iterator(_First, #_First) \
235 ._M_iterator(_Last, #_Last))
239 #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \
240 __glibcxx_check_valid_range(_First,_Last); \
241 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
242 __gnu_debug::__base(_First), \
243 __gnu_debug::__base(_Last), _Pred), \
244 _M_message(__gnu_debug::__msg_unsorted_pred) \
245 ._M_iterator(_First, #_First) \
246 ._M_iterator(_Last, #_Last) \
250 #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \
251 __glibcxx_check_valid_range(_First1,_Last1); \
252 _GLIBCXX_DEBUG_VERIFY( \
253 __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
254 __gnu_debug::__base(_Last1), _First2),\
255 _M_message(__gnu_debug::__msg_unsorted) \
256 ._M_iterator(_First1, #_First1) \
257 ._M_iterator(_Last1, #_Last1))
260 #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
261 __glibcxx_check_valid_range(_First1,_Last1); \
262 _GLIBCXX_DEBUG_VERIFY( \
263 __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
264 __gnu_debug::__base(_Last1), \
266 _M_message(__gnu_debug::__msg_unsorted_pred) \
267 ._M_iterator(_First1, #_First1) \
268 ._M_iterator(_Last1, #_Last1) \
273 #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \
274 __glibcxx_check_valid_range(_First,_Last); \
275 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
276 __gnu_debug::__base(_First), \
277 __gnu_debug::__base(_Last), _Value), \
278 _M_message(__gnu_debug::__msg_unpartitioned) \
279 ._M_iterator(_First, #_First) \
280 ._M_iterator(_Last, #_Last) \
283 #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \
284 __glibcxx_check_valid_range(_First,_Last); \
285 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
286 __gnu_debug::__base(_First), \
287 __gnu_debug::__base(_Last), _Value), \
288 _M_message(__gnu_debug::__msg_unpartitioned) \
289 ._M_iterator(_First, #_First) \
290 ._M_iterator(_Last, #_Last) \
295 #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
296 __glibcxx_check_valid_range(_First,_Last); \
297 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
298 __gnu_debug::__base(_First), \
299 __gnu_debug::__base(_Last), _Value, _Pred), \
300 _M_message(__gnu_debug::__msg_unpartitioned_pred) \
301 ._M_iterator(_First, #_First) \
302 ._M_iterator(_Last, #_Last) \
308 #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
309 __glibcxx_check_valid_range(_First,_Last); \
310 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
311 __gnu_debug::__base(_First), \
312 __gnu_debug::__base(_Last), _Value, _Pred), \
313 _M_message(__gnu_debug::__msg_unpartitioned_pred) \
314 ._M_iterator(_First, #_First) \
315 ._M_iterator(_Last, #_Last) \
320 #define __glibcxx_check_heap(_First,_Last) \
321 _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
322 __gnu_debug::__base(_Last)), \
323 _M_message(__gnu_debug::__msg_not_heap) \
324 ._M_iterator(_First, #_First) \
325 ._M_iterator(_Last, #_Last))
329 #define __glibcxx_check_heap_pred(_First,_Last,_Pred) \
330 _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \
331 __gnu_debug::__base(_Last), \
333 _M_message(__gnu_debug::__msg_not_heap_pred) \
334 ._M_iterator(_First, #_First) \
335 ._M_iterator(_Last, #_Last) \
339 #define __glibcxx_check_self_move_assign(_Other) \
340 _GLIBCXX_DEBUG_VERIFY(this != &_Other, \
341 _M_message(__gnu_debug::__msg_self_move_assign) \
342 ._M_sequence(*this, "this"))
345 #define __glibcxx_check_max_load_factor(_F) \
346 _GLIBCXX_DEBUG_VERIFY(_F > 0.0f, \
347 _M_message(__gnu_debug::__msg_valid_load_factor) \
348 ._M_sequence(*this, "this"))
350 #define __glibcxx_check_equal_allocs(_Other) \
351 _GLIBCXX_DEBUG_VERIFY(this->get_allocator() == _Other.get_allocator(), \
352 _M_message(__gnu_debug::__msg_equal_allocs) \
353 ._M_sequence(*this, "this"))
355 #ifdef _GLIBCXX_DEBUG_PEDANTIC
356 # define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0)
357 # define __glibcxx_check_string_len(_String,_Len) \
358 _GLIBCXX_DEBUG_ASSERT(_String != 0 || _Len == 0)
360 # define __glibcxx_check_string(_String)
361 # define __glibcxx_check_string_len(_String,_Len)