22namespace bio::ranges::detail
43template <
typename value_t>
44class repeat_view :
public std::ranges::view_interface<repeat_view<value_t>>
48 using base_t = std::ranges::view_interface<repeat_view<value_t>>;
51 using sentinel_type = std::default_sentinel_t;
54 using single_value_t = value_t;
63 using reference = value_type &;
65 using const_reference = value_type
const &;
67 using difference_type = ptrdiff_t;
71 template <
typename parent_type>
78 using iterator = basic_iterator<repeat_view>;
80 using const_iterator = basic_iterator<repeat_view const>;
84 template <
typename,
template <
typename...>
typename>
85 friend class detail::random_access_iterator_base;
91 repeat_view() =
default;
92 repeat_view(repeat_view
const &) =
default;
93 repeat_view & operator=(repeat_view
const &) =
default;
94 repeat_view(repeat_view &&) noexcept = default;
95 repeat_view & operator=(repeat_view &&) noexcept = default;
96 ~repeat_view() = default;
99 constexpr explicit repeat_view(value_t const & value)
100 requires
std::copy_constructible<value_t>
101 : single_value{value}
106 constexpr explicit repeat_view(value_t && value) : single_value{
std::
move(value)} {}
127 constexpr iterator
begin() noexcept {
return iterator{*
this}; }
130 constexpr const_iterator
begin() const noexcept {
return const_iterator{*
this}; }
147 constexpr sentinel_type
end() noexcept {
return {}; }
150 constexpr sentinel_type
end() const noexcept {
return {}; }
172 constexpr const_reference operator[](difference_type
const BIOCPP_DOXYGEN_ONLY(n))
const noexcept
178 constexpr reference operator[](difference_type
const BIOCPP_DOXYGEN_ONLY(n))
noexcept {
return single_value; }
183 single_value_t single_value;
187template <
typename value_t>
188template <
typename parent_type>
189class repeat_view<value_t>::basic_iterator :
public detail::random_access_iterator_base<parent_type, basic_iterator>
192 using base_t = detail::random_access_iterator_base<parent_type, basic_iterator>;
195 using typename base_t::position_type;
199 using typename base_t::difference_type;
201 using typename base_t::value_type;
203 using typename base_t::reference;
205 using typename base_t::pointer;
207 using typename base_t::iterator_category;
212 basic_iterator() =
default;
213 basic_iterator(basic_iterator
const &) =
default;
214 basic_iterator & operator=(basic_iterator
const &) =
default;
215 basic_iterator(basic_iterator &&) noexcept = default;
216 basic_iterator & operator=(basic_iterator &&) noexcept = default;
217 ~basic_iterator() = default;
222 explicit constexpr basic_iterator(parent_type & host) noexcept : base_t{host} {}
227 template <
typename parent_type2>
228 requires(std::is_const_v<parent_type> && (!std::is_const_v<parent_type2>) &&
230 constexpr basic_iterator(basic_iterator<parent_type2>
const & rhs) noexcept : base_t{rhs}
238 friend constexpr bool operator==(basic_iterator
const &, std::default_sentinel_t
const &)
noexcept {
return false; }
250 template <
typename value_t>
251 constexpr auto operator()(value_t && value)
const
253 static_assert(std::constructible_from<std::remove_cvref_t<value_t>, value_t>,
254 "The value passed to views::repeat must be (1) an lvalue and its type copy constructible; or "
255 "(2) an rvalue and its type move constructible.");
257 return detail::repeat_view{std::forward<value_t>(value)};
314inline constexpr detail::repeat_fn
repeat{};
constexpr detail::repeat_fn repeat
A view factory that repeats a given value infinitely.
Definition: repeat.hpp:314
The BioC++ namespace for views.
Provides the bio::ranges::detail::random_access_iterator class.
Provides various transformation traits used by the range module.