xref: /dflybsd-src/contrib/gcc-8.0/libstdc++-v3/include/debug/macros.h (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj // Debugging support implementation -*- C++ -*-
2*38fd1498Szrj 
3*38fd1498Szrj // Copyright (C) 2003-2018 Free Software Foundation, Inc.
4*38fd1498Szrj //
5*38fd1498Szrj // This file is part of the GNU ISO C++ Library.  This library is free
6*38fd1498Szrj // software; you can redistribute it and/or modify it under the
7*38fd1498Szrj // terms of the GNU General Public License as published by the
8*38fd1498Szrj // Free Software Foundation; either version 3, or (at your option)
9*38fd1498Szrj // any later version.
10*38fd1498Szrj 
11*38fd1498Szrj // This library is distributed in the hope that it will be useful,
12*38fd1498Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of
13*38fd1498Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*38fd1498Szrj // GNU General Public License for more details.
15*38fd1498Szrj 
16*38fd1498Szrj // Under Section 7 of GPL version 3, you are granted additional
17*38fd1498Szrj // permissions described in the GCC Runtime Library Exception, version
18*38fd1498Szrj // 3.1, as published by the Free Software Foundation.
19*38fd1498Szrj 
20*38fd1498Szrj // You should have received a copy of the GNU General Public License and
21*38fd1498Szrj // a copy of the GCC Runtime Library Exception along with this program;
22*38fd1498Szrj // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23*38fd1498Szrj // <http://www.gnu.org/licenses/>.
24*38fd1498Szrj 
25*38fd1498Szrj /** @file debug/macros.h
26*38fd1498Szrj  *  This file is a GNU debug extension to the Standard C++ Library.
27*38fd1498Szrj  */
28*38fd1498Szrj 
29*38fd1498Szrj #ifndef _GLIBCXX_DEBUG_MACROS_H
30*38fd1498Szrj #define _GLIBCXX_DEBUG_MACROS_H 1
31*38fd1498Szrj 
32*38fd1498Szrj /**
33*38fd1498Szrj  * Macros used by the implementation to verify certain
34*38fd1498Szrj  * properties. These macros may only be used directly by the debug
35*38fd1498Szrj  * wrappers. Note that these are macros (instead of the more obviously
36*38fd1498Szrj  * @a correct choice of making them functions) because we need line and
37*38fd1498Szrj  * file information at the call site, to minimize the distance between
38*38fd1498Szrj  * the user error and where the error is reported.
39*38fd1498Szrj  *
40*38fd1498Szrj  */
41*38fd1498Szrj #define _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,_File,_Line)	\
42*38fd1498Szrj   do									\
43*38fd1498Szrj   {									\
44*38fd1498Szrj     if (! (_Condition))							\
45*38fd1498Szrj       __gnu_debug::_Error_formatter::_M_at(_File, _Line)		\
46*38fd1498Szrj 	  ._ErrorMessage._M_error();					\
47*38fd1498Szrj   } while (false)
48*38fd1498Szrj 
49*38fd1498Szrj #define _GLIBCXX_DEBUG_VERIFY(_Condition,_ErrorMessage)			\
50*38fd1498Szrj   _GLIBCXX_DEBUG_VERIFY_AT(_Condition,_ErrorMessage,__FILE__,__LINE__)
51*38fd1498Szrj 
52*38fd1498Szrj // Verify that [_First, _Last) forms a valid iterator range.
53*38fd1498Szrj #define __glibcxx_check_valid_range(_First,_Last)			\
54*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last),	\
55*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_valid_range)	\
56*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
57*38fd1498Szrj 		      ._M_iterator(_Last, #_Last))
58*38fd1498Szrj 
59*38fd1498Szrj #define __glibcxx_check_valid_range2(_First,_Last,_Dist)		\
60*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last, _Dist),	\
61*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_valid_range)	\
62*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
63*38fd1498Szrj 		      ._M_iterator(_Last, #_Last))
64*38fd1498Szrj 
65*38fd1498Szrj // Verify that [_First, _Last) forms a non-empty iterator range.
66*38fd1498Szrj #define __glibcxx_check_non_empty_range(_First,_Last)			\
67*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_First != _Last,					\
68*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_non_empty_range)	\
69*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
70*38fd1498Szrj 		      ._M_iterator(_Last, #_Last))
71*38fd1498Szrj 
72*38fd1498Szrj /** Verify that we can insert into *this with the iterator _Position.
73*38fd1498Szrj  *  Insertion into a container at a specific position requires that
74*38fd1498Szrj  *  the iterator be nonsingular, either dereferenceable or past-the-end,
75*38fd1498Szrj  *  and that it reference the sequence we are inserting into. Note that
76*38fd1498Szrj  *  this macro is only valid when the container is a_Safe_sequence and
77*38fd1498Szrj  *  the iterator is a _Safe_iterator.
78*38fd1498Szrj */
79*38fd1498Szrj #define __glibcxx_check_insert(_Position)				\
80*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(),				\
81*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_insert_singular)	\
82*38fd1498Szrj 		      ._M_sequence(*this, "this")			\
83*38fd1498Szrj 		      ._M_iterator(_Position, #_Position));		\
84*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this),			\
85*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_insert_different)	\
86*38fd1498Szrj 		      ._M_sequence(*this, "this")			\
87*38fd1498Szrj 		      ._M_iterator(_Position, #_Position))
88*38fd1498Szrj 
89*38fd1498Szrj /** Verify that we can insert into *this after the iterator _Position.
90*38fd1498Szrj  *  Insertion into a container after a specific position requires that
91*38fd1498Szrj  *  the iterator be nonsingular, either dereferenceable or before-begin,
92*38fd1498Szrj  *  and that it reference the sequence we are inserting into. Note that
93*38fd1498Szrj  *  this macro is only valid when the container is a_Safe_sequence and
94*38fd1498Szrj  *  the iterator is a _Safe_iterator.
95*38fd1498Szrj */
96*38fd1498Szrj #define __glibcxx_check_insert_after(_Position)				\
97*38fd1498Szrj __glibcxx_check_insert(_Position);					\
98*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(!_Position._M_is_end(),				\
99*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_insert_after_end)	\
100*38fd1498Szrj 		      ._M_sequence(*this, "this")			\
101*38fd1498Szrj 		      ._M_iterator(_Position, #_Position))
102*38fd1498Szrj 
103*38fd1498Szrj /** Verify that we can insert the values in the iterator range
104*38fd1498Szrj  *  [_First, _Last) into *this with the iterator _Position.  Insertion
105*38fd1498Szrj  *  into a container at a specific position requires that the iterator
106*38fd1498Szrj  *  be nonsingular (i.e., either dereferenceable or past-the-end),
107*38fd1498Szrj  *  that it reference the sequence we are inserting into, and that the
108*38fd1498Szrj  *  iterator range [_First, _Last) is a valid (possibly empty)
109*38fd1498Szrj  *  range which does not reference the sequence we are inserting into.
110*38fd1498Szrj  *  Note that this macro is only valid when the container is a
111*38fd1498Szrj  *  _Safe_sequence and the _Position iterator is a _Safe_iterator.
112*38fd1498Szrj */
113*38fd1498Szrj #define __glibcxx_check_insert_range(_Position,_First,_Last,_Dist)	\
114*38fd1498Szrj __glibcxx_check_valid_range2(_First,_Last,_Dist);			\
115*38fd1498Szrj __glibcxx_check_insert(_Position);					\
116*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
117*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_insert_range_from_self)\
118*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
119*38fd1498Szrj 		      ._M_iterator(_Last, #_Last)			\
120*38fd1498Szrj 		      ._M_sequence(*this, "this"))
121*38fd1498Szrj 
122*38fd1498Szrj /** Verify that we can insert the values in the iterator range
123*38fd1498Szrj  *  [_First, _Last) into *this after the iterator _Position.  Insertion
124*38fd1498Szrj  *  into a container after a specific position requires that the iterator
125*38fd1498Szrj  *  be nonsingular (i.e., either dereferenceable or past-the-end),
126*38fd1498Szrj  *  that it reference the sequence we are inserting into, and that the
127*38fd1498Szrj  *  iterator range [_First, _Last) is a valid (possibly empty)
128*38fd1498Szrj  *  range which does not reference the sequence we are inserting into.
129*38fd1498Szrj  *  Note that this macro is only valid when the container is a
130*38fd1498Szrj  *  _Safe_sequence and the _Position iterator is a _Safe_iterator.
131*38fd1498Szrj */
132*38fd1498Szrj #define __glibcxx_check_insert_range_after(_Position,_First,_Last,_Dist)\
133*38fd1498Szrj   __glibcxx_check_valid_range2(_First,_Last,_Dist);			\
134*38fd1498Szrj __glibcxx_check_insert_after(_Position);				\
135*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
136*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_insert_range_from_self)\
137*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
138*38fd1498Szrj 		      ._M_iterator(_Last, #_Last)			\
139*38fd1498Szrj 		      ._M_sequence(*this, "this"))
140*38fd1498Szrj 
141*38fd1498Szrj /** Verify that we can erase the element referenced by the iterator
142*38fd1498Szrj  * _Position. We can erase the element if the _Position iterator is
143*38fd1498Szrj  * dereferenceable and references this sequence.
144*38fd1498Szrj */
145*38fd1498Szrj #define __glibcxx_check_erase(_Position)				\
146*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(),			\
147*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_erase_bad)	        \
148*38fd1498Szrj                       ._M_sequence(*this, "this")			\
149*38fd1498Szrj 		      ._M_iterator(_Position, #_Position));		\
150*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this),			\
151*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_erase_different)    \
152*38fd1498Szrj 		      ._M_sequence(*this, "this")			\
153*38fd1498Szrj 		      ._M_iterator(_Position, #_Position))
154*38fd1498Szrj 
155*38fd1498Szrj /** Verify that we can erase the element after the iterator
156*38fd1498Szrj  * _Position. We can erase the element if the _Position iterator is
157*38fd1498Szrj  * before a dereferenceable one and references this sequence.
158*38fd1498Szrj */
159*38fd1498Szrj #define __glibcxx_check_erase_after(_Position)				\
160*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_Position._M_before_dereferenceable(),		\
161*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_erase_after_bad)	\
162*38fd1498Szrj 		      ._M_sequence(*this, "this")			\
163*38fd1498Szrj 		      ._M_iterator(_Position, #_Position));		\
164*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this),			\
165*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_erase_different)	\
166*38fd1498Szrj 		      ._M_sequence(*this, "this")			\
167*38fd1498Szrj 		      ._M_iterator(_Position, #_Position))
168*38fd1498Szrj 
169*38fd1498Szrj /** Verify that we can erase the elements in the iterator range
170*38fd1498Szrj  *  [_First, _Last). We can erase the elements if [_First, _Last) is a
171*38fd1498Szrj  *  valid iterator range within this sequence.
172*38fd1498Szrj */
173*38fd1498Szrj #define __glibcxx_check_erase_range(_First,_Last)			\
174*38fd1498Szrj __glibcxx_check_valid_range(_First,_Last);				\
175*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this),			\
176*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_erase_different)    \
177*38fd1498Szrj                       ._M_sequence(*this, "this")			\
178*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
179*38fd1498Szrj 		      ._M_iterator(_Last, #_Last))
180*38fd1498Szrj 
181*38fd1498Szrj /** Verify that we can erase the elements in the iterator range
182*38fd1498Szrj  *  (_First, _Last). We can erase the elements if (_First, _Last) is a
183*38fd1498Szrj  *  valid iterator range within this sequence.
184*38fd1498Szrj */
185*38fd1498Szrj #define __glibcxx_check_erase_range_after(_First,_Last)			\
186*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_First._M_can_compare(_Last),			\
187*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_erase_different)	\
188*38fd1498Szrj 		      ._M_sequence(*this, "this")			\
189*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
190*38fd1498Szrj 		      ._M_iterator(_Last, #_Last));			\
191*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this),			\
192*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_erase_different)	\
193*38fd1498Szrj 		      ._M_sequence(*this, "this")			\
194*38fd1498Szrj 		      ._M_iterator(_First, #_First));			\
195*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_First != _Last,					\
196*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_valid_range2)	\
197*38fd1498Szrj 		      ._M_sequence(*this, "this")			\
198*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
199*38fd1498Szrj 		      ._M_iterator(_Last, #_Last));			\
200*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_First._M_incrementable(),			\
201*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_valid_range2)	\
202*38fd1498Szrj 		      ._M_sequence(*this, "this")			\
203*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
204*38fd1498Szrj 		      ._M_iterator(_Last, #_Last));			\
205*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(),			\
206*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_valid_range2)	\
207*38fd1498Szrj 		      ._M_sequence(*this, "this")			\
208*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
209*38fd1498Szrj 		      ._M_iterator(_Last, #_Last))			\
210*38fd1498Szrj 
211*38fd1498Szrj // Verify that the subscript _N is less than the container's size.
212*38fd1498Szrj #define __glibcxx_check_subscript(_N)					\
213*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_N < this->size(),				\
214*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_subscript_oob)	\
215*38fd1498Szrj                       ._M_sequence(*this, "this")			\
216*38fd1498Szrj 		      ._M_integer(_N, #_N)				\
217*38fd1498Szrj 		      ._M_integer(this->size(), "size"))
218*38fd1498Szrj 
219*38fd1498Szrj // Verify that the bucket _N is less than the container's buckets count.
220*38fd1498Szrj #define __glibcxx_check_bucket_index(_N)				\
221*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_N < this->bucket_count(),			\
222*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_bucket_index_oob)	\
223*38fd1498Szrj                       ._M_sequence(*this, "this")			\
224*38fd1498Szrj 		      ._M_integer(_N, #_N)				\
225*38fd1498Szrj 		      ._M_integer(this->bucket_count(), "size"))
226*38fd1498Szrj 
227*38fd1498Szrj // Verify that the container is nonempty
228*38fd1498Szrj #define __glibcxx_check_nonempty()					\
229*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(! this->empty(),					\
230*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_empty)	        \
231*38fd1498Szrj                       ._M_sequence(*this, "this"))
232*38fd1498Szrj 
233*38fd1498Szrj // Verify that the iterator range [_First, _Last) is sorted
234*38fd1498Szrj #define __glibcxx_check_sorted(_First,_Last)				\
235*38fd1498Szrj __glibcxx_check_valid_range(_First,_Last);				\
236*38fd1498Szrj  _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(			\
237*38fd1498Szrj 			__gnu_debug::__base(_First),			\
238*38fd1498Szrj 			__gnu_debug::__base(_Last)),			\
239*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_unsorted)	        \
240*38fd1498Szrj                       ._M_iterator(_First, #_First)			\
241*38fd1498Szrj 		      ._M_iterator(_Last, #_Last))
242*38fd1498Szrj 
243*38fd1498Szrj /** Verify that the iterator range [_First, _Last) is sorted by the
244*38fd1498Szrj     predicate _Pred. */
245*38fd1498Szrj #define __glibcxx_check_sorted_pred(_First,_Last,_Pred)			\
246*38fd1498Szrj __glibcxx_check_valid_range(_First,_Last);				\
247*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(			\
248*38fd1498Szrj 			__gnu_debug::__base(_First),			\
249*38fd1498Szrj 			__gnu_debug::__base(_Last), _Pred),		\
250*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_unsorted_pred)      \
251*38fd1498Szrj                       ._M_iterator(_First, #_First)			\
252*38fd1498Szrj 		      ._M_iterator(_Last, #_Last)			\
253*38fd1498Szrj 		      ._M_string(#_Pred))
254*38fd1498Szrj 
255*38fd1498Szrj // Special variant for std::merge, std::includes, std::set_*
256*38fd1498Szrj #define __glibcxx_check_sorted_set(_First1,_Last1,_First2)		\
257*38fd1498Szrj __glibcxx_check_valid_range(_First1,_Last1);				\
258*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(                                                  \
259*38fd1498Szrj   __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1),		\
260*38fd1498Szrj 				  __gnu_debug::__base(_Last1), _First2),\
261*38fd1498Szrj   _M_message(__gnu_debug::__msg_unsorted)				\
262*38fd1498Szrj   ._M_iterator(_First1, #_First1)					\
263*38fd1498Szrj   ._M_iterator(_Last1, #_Last1))
264*38fd1498Szrj 
265*38fd1498Szrj // Likewise with a _Pred.
266*38fd1498Szrj #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred)	\
267*38fd1498Szrj __glibcxx_check_valid_range(_First1,_Last1);        			\
268*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(							\
269*38fd1498Szrj   __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1),		\
270*38fd1498Szrj 				  __gnu_debug::__base(_Last1),		\
271*38fd1498Szrj 				  _First2, _Pred),			\
272*38fd1498Szrj   _M_message(__gnu_debug::__msg_unsorted_pred)				\
273*38fd1498Szrj   ._M_iterator(_First1, #_First1)					\
274*38fd1498Szrj   ._M_iterator(_Last1, #_Last1)						\
275*38fd1498Szrj   ._M_string(#_Pred))
276*38fd1498Szrj 
277*38fd1498Szrj /** Verify that the iterator range [_First, _Last) is partitioned
278*38fd1498Szrj     w.r.t. the value _Value. */
279*38fd1498Szrj #define __glibcxx_check_partitioned_lower(_First,_Last,_Value)		\
280*38fd1498Szrj __glibcxx_check_valid_range(_First,_Last);				\
281*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(		\
282*38fd1498Szrj 			__gnu_debug::__base(_First),			\
283*38fd1498Szrj 			__gnu_debug::__base(_Last), _Value),		\
284*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_unpartitioned)      \
285*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
286*38fd1498Szrj 		      ._M_iterator(_Last, #_Last)			\
287*38fd1498Szrj 		      ._M_string(#_Value))
288*38fd1498Szrj 
289*38fd1498Szrj #define __glibcxx_check_partitioned_upper(_First,_Last,_Value)		\
290*38fd1498Szrj __glibcxx_check_valid_range(_First,_Last);				\
291*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(		\
292*38fd1498Szrj 			__gnu_debug::__base(_First),			\
293*38fd1498Szrj 			__gnu_debug::__base(_Last), _Value),		\
294*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_unpartitioned)      \
295*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
296*38fd1498Szrj 		      ._M_iterator(_Last, #_Last)			\
297*38fd1498Szrj 		      ._M_string(#_Value))
298*38fd1498Szrj 
299*38fd1498Szrj /** Verify that the iterator range [_First, _Last) is partitioned
300*38fd1498Szrj     w.r.t. the value _Value and predicate _Pred. */
301*38fd1498Szrj #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
302*38fd1498Szrj __glibcxx_check_valid_range(_First,_Last);				\
303*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(		\
304*38fd1498Szrj 			__gnu_debug::__base(_First),			\
305*38fd1498Szrj 			__gnu_debug::__base(_Last), _Value, _Pred),	\
306*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_unpartitioned_pred) \
307*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
308*38fd1498Szrj 		      ._M_iterator(_Last, #_Last)			\
309*38fd1498Szrj 		      ._M_string(#_Pred)				\
310*38fd1498Szrj                       ._M_string(#_Value))
311*38fd1498Szrj 
312*38fd1498Szrj /** Verify that the iterator range [_First, _Last) is partitioned
313*38fd1498Szrj     w.r.t. the value _Value and predicate _Pred. */
314*38fd1498Szrj #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
315*38fd1498Szrj __glibcxx_check_valid_range(_First,_Last);				\
316*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(		\
317*38fd1498Szrj 			__gnu_debug::__base(_First),			\
318*38fd1498Szrj 			__gnu_debug::__base(_Last), _Value, _Pred),	\
319*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_unpartitioned_pred) \
320*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
321*38fd1498Szrj 		      ._M_iterator(_Last, #_Last)			\
322*38fd1498Szrj 		      ._M_string(#_Pred)				\
323*38fd1498Szrj                       ._M_string(#_Value))
324*38fd1498Szrj 
325*38fd1498Szrj // Verify that the iterator range [_First, _Last) is a heap
326*38fd1498Szrj #define __glibcxx_check_heap(_First,_Last)				\
327*38fd1498Szrj   _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First),	\
328*38fd1498Szrj 				       __gnu_debug::__base(_Last)),	\
329*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_not_heap)	        \
330*38fd1498Szrj 		      ._M_iterator(_First, #_First)			\
331*38fd1498Szrj 		      ._M_iterator(_Last, #_Last))
332*38fd1498Szrj 
333*38fd1498Szrj /** Verify that the iterator range [_First, _Last) is a heap
334*38fd1498Szrj     w.r.t. the predicate _Pred. */
335*38fd1498Szrj #define __glibcxx_check_heap_pred(_First,_Last,_Pred)			\
336*38fd1498Szrj   _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First),	\
337*38fd1498Szrj 				       __gnu_debug::__base(_Last),	\
338*38fd1498Szrj 				       _Pred),				\
339*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_not_heap_pred)      \
340*38fd1498Szrj                       ._M_iterator(_First, #_First)			\
341*38fd1498Szrj 		      ._M_iterator(_Last, #_Last)			\
342*38fd1498Szrj 		      ._M_string(#_Pred))
343*38fd1498Szrj 
344*38fd1498Szrj // Verify that the container is not self move assigned
345*38fd1498Szrj #define __glibcxx_check_self_move_assign(_Other)			\
346*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(this != &_Other,					\
347*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_self_move_assign)	\
348*38fd1498Szrj                       ._M_sequence(*this, "this"))
349*38fd1498Szrj 
350*38fd1498Szrj // Verify that load factor is positive
351*38fd1498Szrj #define __glibcxx_check_max_load_factor(_F)				\
352*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_F > 0.0f,					\
353*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_valid_load_factor)	\
354*38fd1498Szrj                       ._M_sequence(*this, "this"))
355*38fd1498Szrj 
356*38fd1498Szrj #define __glibcxx_check_equal_allocs(_This, _Other)			\
357*38fd1498Szrj _GLIBCXX_DEBUG_VERIFY(_This.get_allocator() == _Other.get_allocator(),	\
358*38fd1498Szrj 		      _M_message(__gnu_debug::__msg_equal_allocs)	\
359*38fd1498Szrj 		      ._M_sequence(_This, "this"))
360*38fd1498Szrj 
361*38fd1498Szrj #define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_PEDASSERT(_String != 0)
362*38fd1498Szrj #define __glibcxx_check_string_len(_String,_Len) \
363*38fd1498Szrj   _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)
364*38fd1498Szrj 
365*38fd1498Szrj // Verify that a predicate is irreflexive
366*38fd1498Szrj #define __glibcxx_check_irreflexive(_First,_Last)			\
367*38fd1498Szrj   _GLIBCXX_DEBUG_VERIFY(_First == _Last || !(*_First < *_First),	\
368*38fd1498Szrj 			_M_message(__gnu_debug::__msg_irreflexive_ordering) \
369*38fd1498Szrj 			._M_iterator_value_type(_First, "< operator type"))
370*38fd1498Szrj 
371*38fd1498Szrj #if __cplusplus >= 201103L
372*38fd1498Szrj # define __glibcxx_check_irreflexive2(_First,_Last)			\
373*38fd1498Szrj   _GLIBCXX_DEBUG_VERIFY(_First == _Last					\
374*38fd1498Szrj 			|| __gnu_debug::__is_irreflexive(_First),	\
375*38fd1498Szrj 			_M_message(__gnu_debug::__msg_irreflexive_ordering) \
376*38fd1498Szrj 			._M_iterator_value_type(_First, "< operator type"))
377*38fd1498Szrj #else
378*38fd1498Szrj # define __glibcxx_check_irreflexive2(_First,_Last)
379*38fd1498Szrj #endif
380*38fd1498Szrj 
381*38fd1498Szrj #define __glibcxx_check_irreflexive_pred(_First,_Last,_Pred)		\
382*38fd1498Szrj   _GLIBCXX_DEBUG_VERIFY(_First == _Last	|| !_Pred(*_First, *_First),		\
383*38fd1498Szrj 			_M_message(__gnu_debug::__msg_irreflexive_ordering) \
384*38fd1498Szrj 			._M_instance(_Pred, "functor")			\
385*38fd1498Szrj 			._M_iterator_value_type(_First, "ordered type"))
386*38fd1498Szrj 
387*38fd1498Szrj #if __cplusplus >= 201103L
388*38fd1498Szrj # define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred)		\
389*38fd1498Szrj   _GLIBCXX_DEBUG_VERIFY(_First == _Last					\
390*38fd1498Szrj 			||__gnu_debug::__is_irreflexive_pred(_First, _Pred), \
391*38fd1498Szrj 			_M_message(__gnu_debug::__msg_irreflexive_ordering) \
392*38fd1498Szrj 			._M_instance(_Pred, "functor")			\
393*38fd1498Szrj 			._M_iterator_value_type(_First, "ordered type"))
394*38fd1498Szrj #else
395*38fd1498Szrj # define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred)
396*38fd1498Szrj #endif
397*38fd1498Szrj 
398*38fd1498Szrj #endif
399