30 #ifndef _GLIBCXX_DEBUG_FUNCTIONS_H
31 #define _GLIBCXX_DEBUG_FUNCTIONS_H 1
40 template<
typename _Iterator,
typename _Sequence>
45 __check_singular_aux(
const void*) {
return false; }
49 template<
typename _Iterator>
51 __check_singular(_Iterator& __x)
52 {
return __check_singular_aux(&__x); }
55 template<
typename _Tp>
57 __check_singular(
const _Tp* __ptr)
58 {
return __ptr == 0; }
61 template<
typename _Iterator,
typename _Sequence>
68 template<
typename _Iterator>
74 template<
typename _Tp>
80 template<
typename _Iterator,
typename _Sequence>
88 template<
typename _RandomAccessIterator>
91 const _RandomAccessIterator& __last,
93 {
return __last - __first >= 0; }
99 template<
typename _InputIterator>
109 template<
typename _Integral>
117 template<
typename _InputIterator>
120 const _InputIterator& __last, std::__false_type)
122 typedef typename std::iterator_traits<_InputIterator>::iterator_category
132 template<
typename _InputIterator>
136 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
141 template<
typename _Iterator,
typename _Sequence>
145 {
return __first._M_valid_range(__last); }
151 template<
typename _InputIterator>
152 inline _InputIterator
153 __check_valid_range(
const _InputIterator& __first,
154 const _InputIterator& __last
155 __attribute__((__unused__)))
157 __glibcxx_check_valid_range(__first, __last);
162 template<
typename _CharT,
typename _Integer>
165 const _Integer& __n __attribute__((__unused__)))
167 #ifdef _GLIBCXX_DEBUG_PEDANTIC
168 __glibcxx_assert(__s != 0 || __n == 0);
174 template<
typename _CharT>
178 #ifdef _GLIBCXX_DEBUG_PEDANTIC
179 __glibcxx_assert(__s != 0);
186 template<
typename _InputIterator>
188 __check_sorted_aux(
const _InputIterator&,
const _InputIterator&,
194 template<
typename _ForwardIterator>
196 __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last,
199 if (__first == __last)
202 _ForwardIterator __next = __first;
203 for (++__next; __next != __last; __first = __next, ++__next)
204 if (*__next < *__first)
212 template<
typename _InputIterator,
typename _Predicate>
214 __check_sorted_aux(
const _InputIterator&,
const _InputIterator&,
220 template<
typename _ForwardIterator,
typename _Predicate>
222 __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last,
225 if (__first == __last)
228 _ForwardIterator __next = __first;
229 for (++__next; __next != __last; __first = __next, ++__next)
230 if (__pred(*__next, *__first))
237 template<
typename _InputIterator>
239 __check_sorted(
const _InputIterator& __first,
const _InputIterator& __last)
241 typedef typename std::iterator_traits<_InputIterator>::iterator_category
246 __glibcxx_assert(__first == __last || !(*__first < *__first));
248 return __check_sorted_aux(__first, __last, _Category());
251 template<
typename _InputIterator,
typename _Predicate>
253 __check_sorted(
const _InputIterator& __first,
const _InputIterator& __last,
256 typedef typename std::iterator_traits<_InputIterator>::iterator_category
261 __glibcxx_assert(__first == __last || !__pred(*__first, *__first));
263 return __check_sorted_aux(__first, __last, __pred, _Category());
266 template<
typename _InputIterator>
268 __check_sorted_set_aux(
const _InputIterator& __first,
269 const _InputIterator& __last,
271 {
return __check_sorted(__first, __last); }
273 template<
typename _InputIterator>
275 __check_sorted_set_aux(
const _InputIterator&,
276 const _InputIterator&,
280 template<
typename _InputIterator,
typename _Predicate>
282 __check_sorted_set_aux(
const _InputIterator& __first,
283 const _InputIterator& __last,
284 _Predicate __pred, std::__true_type)
285 {
return __check_sorted(__first, __last, __pred); }
287 template<
typename _InputIterator,
typename _Predicate>
289 __check_sorted_set_aux(
const _InputIterator&,
290 const _InputIterator&, _Predicate,
295 template<
typename _InputIterator1,
typename _InputIterator2>
297 __check_sorted_set(
const _InputIterator1& __first,
298 const _InputIterator1& __last,
299 const _InputIterator2&)
301 typedef typename std::iterator_traits<_InputIterator1>::value_type
303 typedef typename std::iterator_traits<_InputIterator2>::value_type
306 typedef typename std::__are_same<_ValueType1, _ValueType2>::__type
308 return __check_sorted_set_aux(__first, __last, _SameType());
311 template<
typename _InputIterator1,
typename _InputIterator2,
314 __check_sorted_set(
const _InputIterator1& __first,
315 const _InputIterator1& __last,
316 const _InputIterator2&, _Predicate __pred)
318 typedef typename std::iterator_traits<_InputIterator1>::value_type
320 typedef typename std::iterator_traits<_InputIterator2>::value_type
323 typedef typename std::__are_same<_ValueType1, _ValueType2>::__type
325 return __check_sorted_set_aux(__first, __last, __pred, _SameType());
331 template<
typename _ForwardIterator,
typename _Tp>
333 __check_partitioned_lower(_ForwardIterator __first,
334 _ForwardIterator __last,
const _Tp& __value)
336 while (__first != __last && *__first < __value)
338 while (__first != __last && !(*__first < __value))
340 return __first == __last;
343 template<
typename _ForwardIterator,
typename _Tp>
345 __check_partitioned_upper(_ForwardIterator __first,
346 _ForwardIterator __last,
const _Tp& __value)
348 while (__first != __last && !(__value < *__first))
350 while (__first != __last && __value < *__first)
352 return __first == __last;
356 template<
typename _ForwardIterator,
typename _Tp,
typename _Pred>
358 __check_partitioned_lower(_ForwardIterator __first,
359 _ForwardIterator __last,
const _Tp& __value,
362 while (__first != __last &&
bool(__pred(*__first, __value)))
364 while (__first != __last && !
bool(__pred(*__first, __value)))
366 return __first == __last;
369 template<
typename _ForwardIterator,
typename _Tp,
typename _Pred>
371 __check_partitioned_upper(_ForwardIterator __first,
372 _ForwardIterator __last,
const _Tp& __value,
375 while (__first != __last && !
bool(__pred(__value, *__first)))
377 while (__first != __last &&
bool(__pred(__value, *__first)))
379 return __first == __last;