29 #ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_TCC 30 #define _GLIBCXX_DEBUG_SAFE_ITERATOR_TCC 1 34 template<
typename _Iterator,
typename _Sequence,
typename _Category>
35 typename _Distance_traits<_Iterator>::__type
36 _Safe_iterator<_Iterator, _Sequence, _Category>::
37 _M_get_distance_from_begin()
const 39 typedef _Sequence_traits<_Sequence> _SeqTraits;
47 return _SeqTraits::_S_size(*_M_get_sequence());
49 typename _Distance_traits<_Iterator>::__type __res
52 if (__res.second == __dp_equality)
58 template<
typename _Iterator,
typename _Sequence,
typename _Category>
59 typename _Distance_traits<_Iterator>::__type
60 _Safe_iterator<_Iterator, _Sequence, _Category>::
61 _M_get_distance_to_end()
const 63 typedef _Sequence_traits<_Sequence> _SeqTraits;
68 return _SeqTraits::_S_size(*_M_get_sequence());
73 typename _Distance_traits<_Iterator>::__type __res
76 if (__res.second == __dp_equality)
82 template<
typename _Iterator,
typename _Sequence,
typename _Category>
84 _Safe_iterator<_Iterator, _Sequence, _Category>::
85 _M_can_advance(difference_type __n)
const 87 if (this->_M_singular())
96 _M_get_distance_from_begin();
97 bool __ok = ((__dist.
second == __dp_exact && __dist.
first >= -__n)
98 || (__dist.
second != __dp_exact && __dist.
first > 0));
104 _M_get_distance_to_end();
105 bool __ok = ((__dist.
second == __dp_exact && __dist.
first >= __n)
106 || (__dist.
second != __dp_exact && __dist.
first > 0));
111 template<
typename _Iterator,
typename _Sequence,
typename _Category>
112 typename _Distance_traits<_Iterator>::__type
113 _Safe_iterator<_Iterator, _Sequence, _Category>::
114 _M_get_distance_to(
const _Safe_iterator& __rhs)
const 116 typedef typename _Distance_traits<_Iterator>::__type _Diff;
117 typedef _Sequence_traits<_Sequence> _SeqTraits;
119 if (this->base() == __rhs.base())
122 if (this->_M_is_before_begin())
124 if (__rhs._M_is_begin())
130 if (this->_M_is_begin())
132 if (__rhs._M_is_before_begin())
135 if (__rhs._M_is_end())
136 return _SeqTraits::_S_size(*this->_M_get_sequence());
141 if (this->_M_is_end())
143 if (__rhs._M_is_before_begin())
146 if (__rhs._M_is_begin())
148 _Diff __diff = _SeqTraits::_S_size(*this->_M_get_sequence());
155 if (__rhs._M_is_before_begin() || __rhs._M_is_begin())
158 if (__rhs._M_is_end())
164 template<
typename _Iterator,
typename _Sequence,
typename _Category>
166 _Safe_iterator<_Iterator, _Sequence, _Category>::
167 _M_valid_range(
const _Safe_iterator& __rhs,
169 bool __check_dereferenceable)
const 171 if (!_M_can_compare(__rhs))
175 __dist = _M_get_distance_to(__rhs);
179 if (__dist.
first == 0)
186 if (__dist.
first > 0)
187 return !__check_dereferenceable || _M_dereferenceable();
188 return __dist.
first == 0;
195 template<
typename _Iterator,
typename _Sequence>
197 _Safe_iterator<_Iterator, _Sequence, std::random_access_iterator_tag>::
198 _M_valid_range(
const _Safe_iterator& __rhs,
202 if (!this->_M_can_compare(__rhs))
209 if (__dist.
first > 0)
210 return this->_M_dereferenceable();
211 return __dist.
first == 0;
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list. ...
_T2 second
first is a copy of the first object
_T1 first
second_type is the second bound type
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
GNU debug classes for public use.
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
Struct holding two objects of arbitrary type.
_Distance_traits< _Iterator >::__type __get_distance(_Iterator __lhs, _Iterator __rhs, std::random_access_iterator_tag)