28namespace bio::ranges::detail
32template <
typename view_t>
41template <std::ranges::view urng_t>
42class single_pass_input_view :
public std::ranges::view_interface<single_pass_input_view<urng_t>>
47 using urng_iterator_type = std::ranges::iterator_t<urng_t>;
50 template <
typename view_t>
51 friend class basic_iterator;
69 using iterator = basic_iterator<single_pass_input_view>;
71 using sentinel = std::ranges::sentinel_t<urng_t>;
80 constexpr single_pass_input_view() =
default;
82 constexpr single_pass_input_view(single_pass_input_view
const &) =
default;
84 constexpr single_pass_input_view(single_pass_input_view &&) noexcept = default;
86 constexpr single_pass_input_view & operator=(single_pass_input_view const &) = default;
88 constexpr single_pass_input_view & operator=(single_pass_input_view &&) noexcept = default;
90 ~single_pass_input_view() = default;
93 explicit single_pass_input_view(urng_t _urng) : state_ptr{
new state{std::move(_urng)}} {}
96 template <meta::different_from<single_pass_input_view> other_urng_t>
97 requires(std::ranges::viewable_range<other_urng_t> &&
98 std::constructible_from<urng_t, std::ranges::ref_view<std::remove_reference_t<other_urng_t>>>)
99 explicit single_pass_input_view(other_urng_t && _urng) : single_pass_input_view{std::views::all(_urng)}
113 iterator
begin() {
return {*
this}; }
116 iterator
begin()
const =
delete;
119 sentinel
end() {
return {std::ranges::end(state_ptr->urng)}; }
122 sentinel
end()
const =
delete;
132template <std::ranges::viewable_range urng_t>
133single_pass_input_view(urng_t &&) -> single_pass_input_view<std::views::all_t<urng_t>>;
141namespace bio::ranges::detail
150template <
typename view_type>
151class basic_iterator<single_pass_input_view<view_type>>
154 using base_iterator_type =
typename single_pass_input_view<view_type>::urng_iterator_type;
156 using sentinel_type =
typename single_pass_input_view<view_type>::sentinel;
159 single_pass_input_view<view_type> * view_ptr{};
162 template <
typename input_view_type>
163 friend class basic_iterator;
166 static_assert(std::sentinel_for<sentinel_type, base_iterator_type>);
177 using pointer = detail::iter_pointer_t<base_iterator_type>;
188 basic_iterator() noexcept = default;
190 constexpr basic_iterator(basic_iterator const & rhs) noexcept = default;
192 constexpr basic_iterator(basic_iterator && rhs) noexcept = default;
194 constexpr basic_iterator & operator=(basic_iterator const & rhs) noexcept = default;
196 constexpr basic_iterator & operator=(basic_iterator && rhs) noexcept = default;
198 ~basic_iterator() noexcept = default;
201 basic_iterator(single_pass_input_view<view_type> & view) noexcept : view_ptr{&view} {}
208 reference operator*() const noexcept {
return *cached(); }
211 pointer operator->() const noexcept
212 requires(!
std::is_void_v<pointer>)
222 basic_iterator & operator++() noexcept
229 auto operator++(
int)
noexcept
231 if constexpr (std::output_iterator<base_iterator_type, reference> &&
232 std::copy_constructible<base_iterator_type>)
234 basic_iterator tmp{*
this};
249 constexpr bool operator==(sentinel_type
const & s)
const noexcept {
return cached() == s; }
252 friend constexpr bool operator==(sentinel_type
const & s, basic_iterator
const & rhs)
noexcept {
return rhs == s; }
258 base_iterator_type & cached() const noexcept
260 assert(view_ptr !=
nullptr);
261 assert(view_ptr->state_ptr !=
nullptr);
262 return view_ptr->state_ptr->cached_urng_iter;
325inline constexpr auto single_pass_input = detail::adaptor_for_view_without_args<detail::single_pass_input_view>{};
constexpr auto single_pass_input
A view adapter that decays most of the range properties and adds single pass behavior.
Definition: single_pass_input.hpp:325
The BioC++ namespace for views.
Auxiliary header for the views submodule .