22namespace bio::ranges::detail
41template <
typename range_type,
template <
typename...>
typename derived_t_template>
42class random_access_iterator_base
50 position_type pos{
static_cast<position_type
>(0)};
53 template <
typename,
template <
typename...>
typename>
54 friend class random_access_iterator_base;
57 using derived_t = derived_t_template<range_type>;
61 using difference_type =
typename range_type::difference_type;
63 using value_type =
typename range_type::value_type;
65 using reference = std::
66 conditional_t<std::is_const_v<range_type>,
typename range_type::const_reference,
typename range_type::reference>;
68 using const_reference =
typename range_type::const_reference;
70 using pointer = value_type *;
78 constexpr random_access_iterator_base() noexcept = default;
80 constexpr random_access_iterator_base(random_access_iterator_base const &) noexcept = default;
82 constexpr random_access_iterator_base & operator=(random_access_iterator_base const &) noexcept = default;
84 constexpr random_access_iterator_base(random_access_iterator_base &&) noexcept = default;
86 constexpr random_access_iterator_base & operator=(random_access_iterator_base &&) noexcept = default;
88 ~random_access_iterator_base() noexcept = default;
91 explicit constexpr random_access_iterator_base(range_type & host) noexcept : host{&host} {}
93 constexpr random_access_iterator_base(range_type & host, position_type
const pos) noexcept : host{&host}, pos{pos}
97 template <
typename range_type2>
98 requires(std::is_const_v<range_type> && (!std::is_const_v<range_type2>) &&
100 constexpr random_access_iterator_base(
101 random_access_iterator_base<range_type2, derived_t_template>
const & rhs) noexcept :
102 host{rhs.host}, pos{rhs.pos}
113 constexpr friend bool operator==(derived_t
const & lhs, derived_t
const & rhs)
noexcept
115 return lhs.pos == rhs.pos;
119 constexpr friend auto operator<=>(derived_t
const & lhs, derived_t
const & rhs)
noexcept
121 return lhs.pos <=> rhs.pos;
130 constexpr derived_t & operator++() noexcept
133 return *this_derived();
137 constexpr derived_t operator++(
int)
noexcept
139 derived_t cpy{*this_derived()};
145 constexpr derived_t & operator--() noexcept
148 return *this_derived();
152 constexpr derived_t operator--(
int)
noexcept
154 derived_t cpy{*this_derived()};
160 constexpr derived_t & operator+=(difference_type
const skip)
noexcept
163 return *this_derived();
167 constexpr derived_t operator+(difference_type
const skip)
const noexcept
169 derived_t cpy{*this_derived()};
174 constexpr friend derived_t operator+(difference_type
const skip, derived_t
const & it)
noexcept
180 constexpr derived_t & operator-=(difference_type
const skip)
noexcept
183 return *this_derived();
187 constexpr derived_t operator-(difference_type
const skip)
const noexcept
189 derived_t cpy{*this_derived()};
194 constexpr friend derived_t operator-(difference_type
const skip, derived_t
const & it)
noexcept
200 constexpr friend difference_type operator-(derived_t
const & lhs, derived_t
const & rhs)
noexcept
202 return static_cast<difference_type
>(lhs.pos - rhs.pos);
211 constexpr reference operator*() const noexcept(noexcept((*host)[pos])) {
return (*host)[pos]; }
214 constexpr pointer operator->() const noexcept(noexcept((&host)[pos])) {
return &host[pos]; }
217 constexpr reference operator[](position_type
const n)
const noexcept(
noexcept((*host)[pos + n]))
219 return (*host)[pos + n];
225 constexpr derived_t * this_derived() {
return static_cast<derived_t *
>(
this); }
228 constexpr derived_t
const * this_derived()
const {
return static_cast<derived_t
const *
>(
this); }
239template <
typename range_type>
240class random_access_iterator :
public random_access_iterator_base<range_type, random_access_iterator>
244 using base = random_access_iterator_base<range_type, random_access_iterator>;
246 using typename base::position_type;
253 using typename base::const_reference;
254 using typename base::difference_type;
255 using typename base::iterator_category;
256 using typename base::pointer;
257 using typename base::reference;
258 using typename base::value_type;
Provides platform and dependency checks.