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