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>
52 {
return __check_singular_aux(&__x); }
55 template<
typename _Tp>
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); }
148 template<
typename _Iterator,
typename _Sequence>
152 {
return __first._M_valid_range(__last); }
158 template<
typename _InputIterator>
159 inline _InputIterator
160 __check_valid_range(
const _InputIterator& __first,
161 const _InputIterator& __last
162 __attribute__((__unused__)))
164 __glibcxx_check_valid_range(__first, __last);
169 template<
typename _CharT,
typename _Integer>
172 const _Integer& __n __attribute__((__unused__)))
174 #ifdef _GLIBCXX_DEBUG_PEDANTIC
175 __glibcxx_assert(__s != 0 || __n == 0);
181 template<
typename _CharT>
185 #ifdef _GLIBCXX_DEBUG_PEDANTIC
186 __glibcxx_assert(__s != 0);
193 template<
typename _InputIterator>
195 __check_sorted_aux(
const _InputIterator&,
const _InputIterator&,
201 template<
typename _ForwardIterator>
203 __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last,
206 if (__first == __last)
209 _ForwardIterator __next = __first;
210 for (++__next; __next != __last; __first = __next, ++__next)
211 if (*__next < *__first)
219 template<
typename _InputIterator,
typename _Predicate>
221 __check_sorted_aux(
const _InputIterator&,
const _InputIterator&,
227 template<
typename _ForwardIterator,
typename _Predicate>
229 __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last,
232 if (__first == __last)
235 _ForwardIterator __next = __first;
236 for (++__next; __next != __last; __first = __next, ++__next)
237 if (__pred(*__next, *__first))
244 template<
typename _InputIterator>
246 __check_sorted(
const _InputIterator& __first,
const _InputIterator& __last)
248 typedef typename std::iterator_traits<_InputIterator>::iterator_category
253 __glibcxx_assert(__first == __last || !(*__first < *__first));
255 return __check_sorted_aux(__first, __last, _Category());
258 template<
typename _InputIterator,
typename _Predicate>
260 __check_sorted(
const _InputIterator& __first,
const _InputIterator& __last,
263 typedef typename std::iterator_traits<_InputIterator>::iterator_category
268 __glibcxx_assert(__first == __last || !__pred(*__first, *__first));
270 return __check_sorted_aux(__first, __last, __pred, _Category());
273 template<
typename _InputIterator>
275 __check_sorted_set_aux(
const _InputIterator& __first,
276 const _InputIterator& __last,
278 {
return __check_sorted(__first, __last); }
280 template<
typename _InputIterator>
282 __check_sorted_set_aux(
const _InputIterator&,
283 const _InputIterator&,
287 template<
typename _InputIterator,
typename _Predicate>
289 __check_sorted_set_aux(
const _InputIterator& __first,
290 const _InputIterator& __last,
291 _Predicate __pred, std::__true_type)
292 {
return __check_sorted(__first, __last, __pred); }
294 template<
typename _InputIterator,
typename _Predicate>
296 __check_sorted_set_aux(
const _InputIterator&,
297 const _InputIterator&, _Predicate,
302 template<
typename _InputIterator1,
typename _InputIterator2>
304 __check_sorted_set(
const _InputIterator1& __first,
305 const _InputIterator1& __last,
306 const _InputIterator2&)
308 typedef typename std::iterator_traits<_InputIterator1>::value_type
310 typedef typename std::iterator_traits<_InputIterator2>::value_type
313 typedef typename std::__are_same<_ValueType1, _ValueType2>::__type
315 return __check_sorted_set_aux(__first, __last, _SameType());
318 template<
typename _InputIterator1,
typename _InputIterator2,
321 __check_sorted_set(
const _InputIterator1& __first,
322 const _InputIterator1& __last,
323 const _InputIterator2&, _Predicate __pred)
325 typedef typename std::iterator_traits<_InputIterator1>::value_type
327 typedef typename std::iterator_traits<_InputIterator2>::value_type
330 typedef typename std::__are_same<_ValueType1, _ValueType2>::__type
332 return __check_sorted_set_aux(__first, __last, __pred, _SameType());
338 template<
typename _ForwardIterator,
typename _Tp>
340 __check_partitioned_lower(_ForwardIterator __first,
341 _ForwardIterator __last,
const _Tp& __value)
343 while (__first != __last && *__first < __value)
345 while (__first != __last && !(*__first < __value))
347 return __first == __last;
350 template<
typename _ForwardIterator,
typename _Tp>
352 __check_partitioned_upper(_ForwardIterator __first,
353 _ForwardIterator __last,
const _Tp& __value)
355 while (__first != __last && !(__value < *__first))
357 while (__first != __last && __value < *__first)
359 return __first == __last;
363 template<
typename _ForwardIterator,
typename _Tp,
typename _Pred>
365 __check_partitioned_lower(_ForwardIterator __first,
366 _ForwardIterator __last,
const _Tp& __value,
369 while (__first != __last &&
bool(__pred(*__first, __value)))
371 while (__first != __last && !
bool(__pred(*__first, __value)))
373 return __first == __last;
376 template<
typename _ForwardIterator,
typename _Tp,
typename _Pred>
378 __check_partitioned_upper(_ForwardIterator __first,
379 _ForwardIterator __last,
const _Tp& __value,
382 while (__first != __last && !
bool(__pred(__value, *__first)))
384 while (__first != __last &&
bool(__pred(__value, *__first)))
386 return __first == __last;
bool __valid_range_aux(const _Integral &, const _Integral &, std::__true_type)
bool __check_singular(const _Safe_iterator< _Iterator, _Sequence > &__x)
bool __valid_range_aux2(const _RandomAccessIterator &__first, const _RandomAccessIterator &__last, std::random_access_iterator_tag)
bool __check_dereferenceable(_Iterator &)
const _CharT * __check_string(const _CharT *__s, const _Integer &__n __attribute__((__unused__)))
Forward iterators support a superset of input iterator operations.
bool _M_dereferenceable() const
Is the iterator dereferenceable?
bool __valid_range(const _InputIterator &__first, const _InputIterator &__last)
Random-access iterators support a superset of bidirectional iterator operations.