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(_Condition,_ErrorMessage) \
46 __gnu_debug::_Error_formatter::_M_at(__FILE__, __LINE__) \
47 ._ErrorMessage._M_error(); \
51 #define __glibcxx_check_valid_range(_First,_Last) \
52 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \
53 _M_message(__gnu_debug::__msg_valid_range) \
54 ._M_iterator(_First, #_First) \
55 ._M_iterator(_Last, #_Last))
64 #define __glibcxx_check_insert(_Position) \
65 _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \
66 _M_message(__gnu_debug::__msg_insert_singular) \
67 ._M_sequence(*this, "this") \
68 ._M_iterator(_Position, #_Position)); \
69 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
70 _M_message(__gnu_debug::__msg_insert_different) \
71 ._M_sequence(*this, "this") \
72 ._M_iterator(_Position, #_Position))
81 #define __glibcxx_check_insert_after(_Position) \
82 __glibcxx_check_insert(_Position); \
83 _GLIBCXX_DEBUG_VERIFY(!_Position._M_is_end(), \
84 _M_message(__gnu_debug::__msg_insert_after_end) \
85 ._M_sequence(*this, "this") \
86 ._M_iterator(_Position, #_Position))
101 #define __glibcxx_check_insert_range(_Position,_First,_Last) \
102 __glibcxx_check_valid_range(_First,_Last); \
103 __glibcxx_check_insert(_Position)
118 #define __glibcxx_check_insert_range_after(_Position,_First,_Last) \
119 __glibcxx_check_valid_range(_First,_Last); \
120 __glibcxx_check_insert_after(_Position)
126 #define __glibcxx_check_erase(_Position) \
127 _GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \
128 _M_message(__gnu_debug::__msg_erase_bad) \
129 ._M_sequence(*this, "this") \
130 ._M_iterator(_Position, #_Position)); \
131 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
132 _M_message(__gnu_debug::__msg_erase_different) \
133 ._M_sequence(*this, "this") \
134 ._M_iterator(_Position, #_Position))
140 #define __glibcxx_check_erase_after(_Position) \
141 _GLIBCXX_DEBUG_VERIFY(_Position._M_before_dereferenceable(), \
142 _M_message(__gnu_debug::__msg_erase_after_bad) \
143 ._M_sequence(*this, "this") \
144 ._M_iterator(_Position, #_Position)); \
145 _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
146 _M_message(__gnu_debug::__msg_erase_different) \
147 ._M_sequence(*this, "this") \
148 ._M_iterator(_Position, #_Position))
154 #define __glibcxx_check_erase_range(_First,_Last) \
155 __glibcxx_check_valid_range(_First,_Last); \
156 _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
157 _M_message(__gnu_debug::__msg_erase_different) \
158 ._M_sequence(*this, "this") \
159 ._M_iterator(_First, #_First) \
160 ._M_iterator(_Last, #_Last))
166 #define __glibcxx_check_erase_range_after(_First,_Last) \
167 _GLIBCXX_DEBUG_VERIFY(_First._M_can_compare(_Last), \
168 _M_message(__gnu_debug::__msg_erase_different) \
169 ._M_sequence(*this, "this") \
170 ._M_iterator(_First, #_First) \
171 ._M_iterator(_Last, #_Last)); \
172 _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \
173 _M_message(__gnu_debug::__msg_erase_different) \
174 ._M_sequence(*this, "this") \
175 ._M_iterator(_First, #_First)); \
176 _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
177 _M_message(__gnu_debug::__msg_valid_range2) \
178 ._M_sequence(*this, "this") \
179 ._M_iterator(_First, #_First) \
180 ._M_iterator(_Last, #_Last)); \
181 _GLIBCXX_DEBUG_VERIFY(_First._M_incrementable(), \
182 _M_message(__gnu_debug::__msg_valid_range2) \
183 ._M_sequence(*this, "this") \
184 ._M_iterator(_First, #_First) \
185 ._M_iterator(_Last, #_Last)); \
186 _GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(), \
187 _M_message(__gnu_debug::__msg_valid_range2) \
188 ._M_sequence(*this, "this") \
189 ._M_iterator(_First, #_First) \
190 ._M_iterator(_Last, #_Last)) \
193 #define __glibcxx_check_subscript(_N) \
194 _GLIBCXX_DEBUG_VERIFY(_N < this->size(), \
195 _M_message(__gnu_debug::__msg_subscript_oob) \
196 ._M_sequence(*this, "this") \
197 ._M_integer(_N, #_N) \
198 ._M_integer(this->size(), "size"))
201 #define __glibcxx_check_nonempty() \
202 _GLIBCXX_DEBUG_VERIFY(! this->empty(), \
203 _M_message(__gnu_debug::__msg_empty) \
204 ._M_sequence(*this, "this"))
207 #define __glibcxx_check_sorted(_First,_Last) \
208 __glibcxx_check_valid_range(_First,_Last); \
209 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last), \
210 _M_message(__gnu_debug::__msg_unsorted) \
211 ._M_iterator(_First, #_First) \
212 ._M_iterator(_Last, #_Last))
216 #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \
217 __glibcxx_check_valid_range(_First,_Last); \
218 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \
219 _M_message(__gnu_debug::__msg_unsorted_pred) \
220 ._M_iterator(_First, #_First) \
221 ._M_iterator(_Last, #_Last) \
225 #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \
226 __glibcxx_check_valid_range(_First1,_Last1); \
227 _GLIBCXX_DEBUG_VERIFY( \
228 __gnu_debug::__check_sorted_set(_First1, _Last1, _First2), \
229 _M_message(__gnu_debug::__msg_unsorted) \
230 ._M_iterator(_First1, #_First1) \
231 ._M_iterator(_Last1, #_Last1))
234 #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
235 __glibcxx_check_valid_range(_First1,_Last1); \
236 _GLIBCXX_DEBUG_VERIFY( \
237 __gnu_debug::__check_sorted_set(_First1, _Last1, _First2, _Pred), \
238 _M_message(__gnu_debug::__msg_unsorted_pred) \
239 ._M_iterator(_First1, #_First1) \
240 ._M_iterator(_Last1, #_Last1) \
245 #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \
246 __glibcxx_check_valid_range(_First,_Last); \
247 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
249 _M_message(__gnu_debug::__msg_unpartitioned) \
250 ._M_iterator(_First, #_First) \
251 ._M_iterator(_Last, #_Last) \
254 #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \
255 __glibcxx_check_valid_range(_First,_Last); \
256 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
258 _M_message(__gnu_debug::__msg_unpartitioned) \
259 ._M_iterator(_First, #_First) \
260 ._M_iterator(_Last, #_Last) \
265 #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
266 __glibcxx_check_valid_range(_First,_Last); \
267 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
269 _M_message(__gnu_debug::__msg_unpartitioned_pred) \
270 ._M_iterator(_First, #_First) \
271 ._M_iterator(_Last, #_Last) \
277 #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
278 __glibcxx_check_valid_range(_First,_Last); \
279 _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
281 _M_message(__gnu_debug::__msg_unpartitioned_pred) \
282 ._M_iterator(_First, #_First) \
283 ._M_iterator(_Last, #_Last) \
288 #define __glibcxx_check_heap(_First,_Last) \
289 _GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last), \
290 _M_message(__gnu_debug::__msg_not_heap) \
291 ._M_iterator(_First, #_First) \
292 ._M_iterator(_Last, #_Last))
296 #define __glibcxx_check_heap_pred(_First,_Last,_Pred) \
297 _GLIBCXX_DEBUG_VERIFY(std::__is_heap(_First, _Last, _Pred), \
298 _M_message(__gnu_debug::__msg_not_heap_pred) \
299 ._M_iterator(_First, #_First) \
300 ._M_iterator(_Last, #_Last) \
303 #ifdef _GLIBCXX_DEBUG_PEDANTIC
304 # define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_ASSERT(_String != 0)
305 # define __glibcxx_check_string_len(_String,_Len) \
306 _GLIBCXX_DEBUG_ASSERT(_String != 0 || _Len == 0)
308 # define __glibcxx_check_string(_String)
309 # define __glibcxx_check_string_len(_String,_Len)