29 #ifndef _GLIBCXX_DEBUG_HELPER_FUNCTIONS_H
30 #define _GLIBCXX_DEBUG_HELPER_FUNCTIONS_H 1
35 #if __cplusplus < 201103L
43 template<
typename _Iterator,
typename _Sequence,
typename _Category>
46 #if __cplusplus >= 201103L
47 template<
typename _Iterator,
typename _Sequence>
48 class _Safe_local_iterator;
63 #if __cplusplus >= 201103L
64 template<
typename _Iterator>
66 template<
typename _Iterator,
67 typename =
typename std::__is_integer<_Iterator>::__type>
69 struct _Distance_traits
75 template<
typename _DiffType,
typename = _DiffType>
77 {
typedef _DiffType __type; };
79 template<
typename _DiffType>
80 struct _DiffTraits<_DiffType, void>
81 {
typedef std::ptrdiff_t __type; };
83 typedef typename _DiffTraits<_ItDiffType>::__type _DiffType;
89 #if __cplusplus < 201103L
90 template<
typename _Integral>
91 struct _Distance_traits<_Integral,
std::__true_type>
98 template<
typename _Iterator>
100 inline typename _Distance_traits<_Iterator>::__type
103 {
return std::make_pair(__rhs - __lhs, __dp_exact); }
105 template<
typename _Iterator>
107 inline typename _Distance_traits<_Iterator>::__type
112 return std::make_pair(0, __dp_exact);
114 return std::make_pair(1, __dp_equality);
117 template<
typename _Iterator>
119 inline typename _Distance_traits<_Iterator>::__type
128 __check_singular_aux(
const void*) {
return false; }
132 __check_singular_aux(
const class _Safe_iterator_base*);
136 template<
typename _Iterator>
139 __check_singular(_Iterator
const& __x)
141 return ! std::__is_constant_evaluated()
146 template<
typename _Tp>
149 __check_singular(_Tp*
const& __ptr)
150 {
return __ptr == 0; }
152 #if __cplusplus < 201103L
154 template<
typename _Integral>
156 __valid_range_aux(_Integral, _Integral, std::__true_type)
159 template<
typename _Integral>
161 __valid_range_aux(_Integral, _Integral,
162 typename _Distance_traits<_Integral>::__type& __dist,
165 __dist = std::make_pair(0, __dp_none);
170 template<
typename _InputIterator>
173 __valid_range_aux(_InputIterator __first, _InputIterator __last,
178 if (std::__is_constant_evaluated())
181 return __first == __last
182 || (!__gnu_debug::__check_singular(__first)
183 && !__gnu_debug::__check_singular(__last));
186 template<
typename _InputIterator>
189 __valid_range_aux(_InputIterator __first, _InputIterator __last,
192 return __gnu_debug::__valid_range_aux(__first, __last,
194 && __first <= __last;
197 #if __cplusplus >= 201103L
198 template<
typename _InputIterator>
200 __valid_range(_InputIterator __first, _InputIterator __last)
205 template<
typename _InputIterator>
207 __valid_range_aux(_InputIterator __first, _InputIterator __last,
211 return __gnu_debug::__valid_range_aux(__first, __last,
215 #if __cplusplus >= 201103L
216 template<
typename _InputIterator>
219 __valid_range(_InputIterator __first, _InputIterator __last,
220 typename _Distance_traits<_InputIterator>::__type& __dist)
222 template<
typename _InputIterator>
224 __valid_range_aux(_InputIterator __first, _InputIterator __last,
225 typename _Distance_traits<_InputIterator>::__type& __dist,
229 if (!__gnu_debug::__valid_range_aux(__first, __last,
234 switch (__dist.second)
239 if (__dist.first == 0)
243 case __dp_sign_max_size:
245 return __dist.first >= 0;
252 #if __cplusplus < 201103L
258 template<
typename _InputIterator>
260 __valid_range(_InputIterator __first, _InputIterator __last,
261 typename _Distance_traits<_InputIterator>::__type& __dist)
263 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
264 return __gnu_debug::__valid_range_aux(__first, __last, __dist,
269 template<
typename _Iterator,
typename _Sequence,
typename _Category>
270 _GLIBCXX20_CONSTEXPR
bool
271 __valid_range(
const _Safe_iterator<_Iterator, _Sequence, _Category>&,
272 const _Safe_iterator<_Iterator, _Sequence, _Category>&,
273 typename _Distance_traits<_Iterator>::__type&);
275 #if __cplusplus >= 201103L
276 template<
typename _Iterator,
typename _Sequence>
278 __valid_range(
const _Safe_local_iterator<_Iterator, _Sequence>&,
279 const _Safe_local_iterator<_Iterator, _Sequence>&,
280 typename _Distance_traits<_Iterator>::__type&);
283 #if __cplusplus < 201103L
284 template<
typename _InputIterator>
286 __valid_range(_InputIterator __first, _InputIterator __last)
288 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
289 return __gnu_debug::__valid_range_aux(__first, __last, _Integral());
293 template<
typename _Iterator,
typename _Sequence,
typename _Category>
294 _GLIBCXX20_CONSTEXPR
bool
295 __valid_range(
const _Safe_iterator<_Iterator, _Sequence, _Category>&,
296 const _Safe_iterator<_Iterator, _Sequence, _Category>&);
298 #if __cplusplus >= 201103L
299 template<
typename _Iterator,
typename _Sequence>
301 __valid_range(
const _Safe_local_iterator<_Iterator, _Sequence>&,
302 const _Safe_local_iterator<_Iterator, _Sequence>&);
306 template<
typename _InputIterator,
typename _Size>
309 __can_advance(_InputIterator, _Size)
312 template<
typename _Iterator,
typename _Sequence,
typename _Category,
314 _GLIBCXX20_CONSTEXPR
bool
315 __can_advance(
const _Safe_iterator<_Iterator, _Sequence, _Category>&,
318 template<
typename _InputIterator,
typename _Diff>
324 template<
typename _Iterator,
typename _Sequence,
typename _Category,
326 _GLIBCXX20_CONSTEXPR
bool
327 __can_advance(
const _Safe_iterator<_Iterator, _Sequence, _Category>&,
336 template<
typename _Iterator>
342 #if __cplusplus < 201103L
343 template<
typename _Iterator>
345 {
typedef _Iterator _Type; };
349 template<
typename _Iterator>
352 __unsafe(_Iterator __it)
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
ISO C++ entities toplevel namespace is std.
GNU debug classes for public use.
constexpr _Distance_traits< _Iterator >::__type __get_distance(_Iterator __lhs, _Iterator __rhs, std::random_access_iterator_tag)
constexpr _Iterator __base(_Iterator __it)
Traits class for iterators.
Struct holding two objects of arbitrary type.
Random-access iterators support a superset of bidirectional iterator operations.