43 (range_cardinality<Rng>::value > 0)
44 ? static_cast<cardinality>(range_cardinality<Rng>::value * 2 - 1)
49 : intersperse_view::view_adaptor{detail::move(rng)}
50 , val_(detail::move(val))
53 constexpr auto CPP_fun(size)()(
const
56 auto const n = ranges::size(this->base());
57 return n ? n * 2 - 1 : 0;
60 constexpr auto CPP_fun(size)()(
63 auto const n = ranges::size(this->base());
64 return n ? n * 2 - 1 : 0;
73 friend struct cursor_adaptor<!Const>;
74 using CRng = meta::const_if_c<Const, Rng>;
76 range_value_t<Rng> val_;
79 cursor_adaptor() =
default;
80 constexpr explicit cursor_adaptor(range_value_t<Rng>
const & val)
84 requires Const AND CPP_NOT(Other))
85 cursor_adaptor(cursor_adaptor<Other> that)
86 : toggle_(that.toggle_)
87 , val_(std::move(that.val_))
89 template<
typename View>
92 auto first = ranges::begin(view.base());
93 toggle_ = first != ranges::end(view.base());
98 return toggle_ ? *it : val_;
103 cursor_adaptor
const & other)
const
107 return it0 == it1 && toggle_ == other.toggle_;
127 cursor_adaptor
const & other)
const
128 -> CPP_ret(range_difference_t<Rng>)(
131 return (other_it - it) * 2 + (other.toggle_ - toggle_);
138 ranges::advance(it, n >= 0 ? (n + toggle_) / 2 : (n - !toggle_) / 2);
147 using CRng = meta::const_if_c<Const, Rng>;
150 sentinel_adaptor() =
default;
151 template(
bool Other)(
152 requires Const AND CPP_NOT(Other))
153 sentinel_adaptor(sentinel_adaptor<Other>)
156 cursor_adaptor<Const>
const &,
157 sentinel_t<CRng>
const & sent)
162 constexpr cursor_adaptor<false> begin_adaptor()
164 return cursor_adaptor<false>{val_};
167 constexpr auto begin_adaptor()
const
168 -> CPP_ret(cursor_adaptor<true>)(
171 return cursor_adaptor<true>{val_};
174 constexpr auto end_adaptor()
175 -> CPP_ret(cursor_adaptor<false>)(
178 return cursor_adaptor<false>{val_};
181 constexpr auto end_adaptor()
noexcept
182 -> CPP_ret(sentinel_adaptor<false>)(
187 template(
bool Const =
true)(
188 requires Const AND
range<meta::const_if_c<Const, Rng>> AND
190 (!single_pass_iterator_<
iterator_t<meta::const_if_c<Const, Rng>>>))
191 constexpr cursor_adaptor<Const> end_adaptor()
const
193 return cursor_adaptor<true>{val_};
195 template(
bool Const =
true)(
196 requires Const AND
range<meta::const_if_c<Const, Rng>> AND
198 single_pass_iterator_<
iterator_t<meta::const_if_c<Const, Rng>>>))
199 constexpr sentinel_adaptor<Const> end_adaptor()
const noexcept
204 range_value_t<Rng> val_;