51 template <std::ranges::view urng_t,
typename fun_t,
bool or_throw,
bool and_consume>
52 class view_take_until :
public std::ranges::view_interface<view_take_until<urng_t, fun_t, or_throw, and_consume>>
56 static_assert(std::invocable<fun_t, std::ranges::range_reference_t<urng_t>>,
57 "The functor type for views::take_until must model"
58 "std::invocable<fun_t, std::ranges::range_reference_t<urng_t>>.");
59 static_assert(std::convertible_to<
std::result_of_t<fun_t&&(std::ranges::range_reference_t<urng_t>)>,
bool>,
60 "The result type of the functor for views::take_until must be a boolean.");
66 ranges::semiregular_t<fun_t>
fun;
70 std::regular_invocable<fun_t, std::ranges::range_reference_t<urng_t>>;
72 template <
typename rng_t>
75 template <
bool is_const_range>
78 template <
typename rng_t>
118 template <std::ranges::viewable_range rng_t>
120 requires std::constructible_from<rng_t, std::views::all_t<rng_t>>
145 return {std::ranges::begin(
urange),
static_cast<fun_t &
>(
fun), std::ranges::end(
urange)};
152 return {std::ranges::cbegin(
urange),
static_cast<fun_t
const &
>(
fun), std::ranges::cend(
urange)};
170 if constexpr (and_consume && !std::ranges::forward_range<urng_t>)
171 return std::ranges::end(
urange);
180 if constexpr (and_consume && !std::ranges::forward_range<urng_t>)
181 return std::ranges::cend(
urange);
190 template <
typename urng_t,
typename fun_t,
bool or_throw = false,
bool and_consume = false>
195 template <std::ranges::view urng_t,
typename fun_t,
bool or_throw,
bool and_consume>
196 template <
typename rng_t>
261 template <std::ranges::view urng_t,
typename fun_t,
bool or_throw,
bool and_consume>
262 template <
typename rng_t>
286 bool at_end_gracefully =
false;
306 if ((this->base() != stored_end) &&
fun(**
this))
308 at_end_gracefully =
true;
331 noexcept(noexcept(++
std::declval<
base_t &>()) &&
335 base_t::operator++();
337 while ((this->base() != stored_end) &&
fun(**
this))
339 at_end_gracefully =
true;
340 base_t::operator++();
348 noexcept(noexcept(++std::declval<basic_consume_iterator &>()) &&
349 std::is_nothrow_copy_constructible_v<basic_consume_iterator>)
362 noexcept(!or_throw &&
363 noexcept(std::declval<base_base_t &>() != std::declval<sentinel_type &>()) &&
364 noexcept(
fun(std::declval<reference>())))
366 if (at_end_gracefully)
369 if (this->base() == rhs)
371 if constexpr (or_throw)
382 noexcept(noexcept(rhs == lhs))
389 noexcept(noexcept(std::declval<basic_consume_iterator &>() == rhs))
391 return !(*
this == rhs);
396 noexcept(noexcept(rhs != lhs))
404 template <std::ranges::view urng_t,
typename fun_t,
bool or_throw,
bool and_consume>
405 template <
bool is_const_range>
440 urng_sentinel{
std::
move(urng_sentinel)},
446 requires is_const_range && std::convertible_to<std::ranges::sentinel_t<urng_t>,
urng_sentinel_type>
447 : urng_sentinel{
std::move(other.urng_sentinel)},
448 predicate{other.predicate}
457 template <
typename rng_t>
463 if constexpr (or_throw)
473 template <
typename rng_t>
480 template <
typename rng_t>
483 return !(lhs == rhs);
487 template <
typename rng_t>
502 template <
bool or_throw,
bool and_consume>
506 template <
typename fun_t>
519 template <std::ranges::viewable_range urng_t,
typename fun_t>
520 constexpr
auto operator()(urng_t && urange, fun_t && fun)
const
524 std::views::all(std::forward<urng_t>(urange)),
525 std::forward<fun_t>(fun)
Adaptations of algorithms from the Ranges TS.
Template for range adaptor closure objects that store arguments and wrap a proto-adaptor.
Definition: detail.hpp:371
A CRTP base template for creating iterators that inherit from other iterators.
Definition: inherited_iterator_base.hpp:52
constexpr base_t base() const &
Get a copy of the base.
Definition: inherited_iterator_base.hpp:111
Special iterator type used when consuming behaviour is selected.
Definition: take_until.hpp:265
seqan3::semiregular_box_t< fun_ref_t > fun
Reference to the functor stored in the view.
Definition: take_until.hpp:277
std::ranges::sentinel_t< rng_t > sentinel_type
The sentinel type is identical to that of the underlying range.
Definition: take_until.hpp:280
constexpr basic_consume_iterator & operator=(basic_consume_iterator &&rhs)=default
Defaulted.
constexpr basic_consume_iterator & operator=(basic_consume_iterator const &rhs)=default
Defaulted.
bool operator!=(sentinel_type const &rhs) const noexcept(noexcept(std::declval< basic_consume_iterator & >()==rhs))
Return the saved at_end state.
Definition: take_until.hpp:388
constexpr basic_consume_iterator(basic_consume_iterator const &rhs)=default
Defaulted.
friend bool operator==(sentinel_type const &lhs, basic_consume_iterator const &rhs) noexcept(noexcept(rhs==lhs))
Return the saved at_end state.
Definition: take_until.hpp:381
basic_consume_iterator operator++(int) noexcept(noexcept(++std::declval< basic_consume_iterator & >()) &&std::is_nothrow_copy_constructible_v< basic_consume_iterator >)
Post-increment implemented via pre-increment.
Definition: take_until.hpp:347
basic_consume_iterator & operator++() noexcept(noexcept(++std::declval< base_t & >()) &&noexcept(std::declval< base_base_t & >() !=std::declval< sentinel_type & >()) &&noexcept(fun(std::declval< reference >())))
Override pre-increment to implement consuming behaviour.
Definition: take_until.hpp:330
std::ranges::iterator_t< rng_t > base_base_t
The iterator type of the underlying range.
Definition: take_until.hpp:268
basic_consume_iterator(base_base_t it, fun_ref_t _fun, sentinel_type sen) noexcept(noexcept(base_t{it}))
Constructor that delegates to the CRTP layer and initialises the callable.
Definition: take_until.hpp:301
bool operator==(sentinel_type const &rhs) const noexcept(!or_throw &&noexcept(std::declval< base_base_t & >() !=std::declval< sentinel_type & >()) &&noexcept(fun(std::declval< reference >())))
Return the saved at_end state.
Definition: take_until.hpp:361
constexpr basic_consume_iterator()=default
Defaulted.
detail::iter_pointer_t< base_base_t > pointer
From base.
Definition: take_until.hpp:321
sentinel_type stored_end
Whether this iterator has reached the end (cache is only used on pure input ranges).
Definition: take_until.hpp:283
~basic_consume_iterator()=default
Defaulted.
constexpr basic_consume_iterator(basic_consume_iterator &&rhs)=default
Defaulted.
friend bool operator!=(sentinel_type const &lhs, basic_consume_iterator const &rhs) noexcept(noexcept(rhs !=lhs))
Return the saved at_end state.
Definition: take_until.hpp:395
The iterator type inherits from the underlying type, but overwrites several operators.
Definition: take_until.hpp:199
std::ranges::sentinel_t< rng_t > sentinel_type
The sentinel type is identical to that of the underlying range.
Definition: take_until.hpp:206
detail::iterator_category_tag_t< base_base_t > iterator_category
The iterator category tag.
Definition: take_until.hpp:253
constexpr basic_iterator & operator=(basic_iterator const &rhs)=default
Defaulted.
constexpr basic_iterator(basic_iterator const &rhs)=default
Defaulted.
~basic_iterator()=default
Defaulted.
constexpr basic_iterator & operator=(basic_iterator &&rhs)=default
Defaulted.
constexpr basic_iterator()=default
Defaulted.
seqan3::semiregular_box_t< fun_ref_t > fun
Reference to the functor stored in the view.
Definition: take_until.hpp:212
std::ranges::iterator_t< rng_t > base_base_t
The iterator type of the underlying range.
Definition: take_until.hpp:202
basic_iterator(base_base_t it, fun_ref_t _fun, sentinel_type) noexcept(noexcept(base_t{it}))
Constructor that delegates to the CRTP layer and initialises the callable.
Definition: take_until.hpp:232
basic_iterator(base_base_t it) noexcept(noexcept(base_t{it}))
Constructor that delegates to the CRTP layer.
Definition: take_until.hpp:227
constexpr basic_iterator(basic_iterator &&rhs)=default
Defaulted.
detail::iter_pointer_t< base_base_t > pointer
The pointer type.
Definition: take_until.hpp:251
The sentinel type of take_until, provides the comparison operators.
Definition: take_until.hpp:407
basic_sentinel(basic_sentinel<!is_const_range > other) requires is_const_range &&std
Construct from a not const range a const range.
Definition: take_until.hpp:445
basic_sentinel(basic_sentinel const &)=default
Defaulted.
urng_sentinel_type urng_sentinel
The actual end of the underlying range.
Definition: take_until.hpp:419
friend bool operator==(basic_iterator< rng_t > const &lhs, basic_sentinel const &rhs)
Compares lhs with rhs for equality.
Definition: take_until.hpp:458
seqan3::semiregular_box_t< predicate_ref_t > predicate
Reference to the predicate stored in the view.
Definition: take_until.hpp:422
~basic_sentinel()=default
Defaulted.
basic_sentinel & operator=(basic_sentinel const &)=default
Defaulted.
basic_sentinel & operator=(basic_sentinel &&)=default
Defaulted.
basic_sentinel(urng_sentinel_type urng_sentinel, predicate_ref_t predicate)
Construct from a sentinel and a predicate.
Definition: take_until.hpp:439
basic_sentinel(basic_sentinel &&)=default
Defaulted.
basic_sentinel()=default
Defaulted.
friend bool operator!=(basic_sentinel const &lhs, basic_iterator< rng_t > const &rhs)
Compares lhs with rhs for inequality.
Definition: take_until.hpp:488
friend bool operator!=(basic_iterator< rng_t > const &lhs, basic_sentinel const &rhs)
Compares lhs with rhs for inequality.
Definition: take_until.hpp:481
friend bool operator==(basic_sentinel const &lhs, basic_iterator< rng_t > const &rhs)
Compares lhs with rhs for equality.
Definition: take_until.hpp:474
std::ranges::sentinel_t< urng_base_type > urng_sentinel_type
The sentinel type of the underlying range.
Definition: take_until.hpp:412
The type returned by seqan3::views::take_until and seqan3::views::take_until_or_throw.
Definition: take_until.hpp:53
constexpr view_take_until(view_take_until &&rhs)=default
Defaulted.
iterator begin() noexcept
Returns an iterator to the first element of the container.
Definition: take_until.hpp:143
view_take_until(urng_t &&, fun_t) -> view_take_until< std::views::all_t< urng_t >, fun_t, or_throw, and_consume >
Type deduction guide that strips references.
constexpr view_take_until & operator=(view_take_until const &rhs)=default
Defaulted.
view_take_until(rng_t &&_urange, fun_t _fun)
Construct from another viewable_range.
Definition: take_until.hpp:122
view_take_until()=default
Defaulted.
const_iterator begin() const noexcept requires const _iterable
Returns an iterator to the first element of the container.
Definition: take_until.hpp:149
view_take_until(urng_t _urange, fun_t _fun)
Construct from another range.
Definition: take_until.hpp:109
urng_t urange
The underlying range.
Definition: take_until.hpp:58
constexpr view_take_until & operator=(view_take_until &&rhs)=default
Defaulted.
static constexpr bool const_iterable
Whether this view is const_iterable or not.
Definition: take_until.hpp:69
constexpr view_take_until(view_take_until const &rhs)=default
Defaulted.
auto end() const noexcept requires const _iterable
Returns an iterator to the element following the last element of the range.
Definition: take_until.hpp:177
ranges::semiregular_t< fun_t > fun
The functor.
Definition: take_until.hpp:66
~view_take_until()=default
Defaulted.
auto end() noexcept
Returns an iterator to the element following the last element of the range.
Definition: take_until.hpp:168
Provides various transformation traits used by the range module.
::ranges::semiregular_box_t semiregular_box_t
Utility transformation trait to get a wrapper type that models std::semiregular. Imported from ranges...
Definition: semiregular_box.hpp:35
constexpr auto take_until_or_throw
A view adaptor that returns elements from the underlying range until the functor evaluates to true (t...
Definition: take_until.hpp:614
constexpr auto take_until
A view adaptor that returns elements from the underlying range until the functor evaluates to true (o...
Definition: take_until.hpp:600
constexpr auto take_until_or_throw_and_consume
A view adaptor that returns elements from the underlying range until the functor evaluates to true (t...
Definition: take_until.hpp:642
auto const move
A view that turns lvalue-references into rvalue-references.
Definition: move.hpp:70
constexpr auto take_until_and_consume
A view adaptor that returns elements from the underlying range until the functor evaluates to true (o...
Definition: take_until.hpp:628
Provides the seqan3::detail::inherited_iterator_base template.
Specifies requirements of an input range type for which the const version of that type satisfies the ...
Provides exceptions used in the I/O module.
Provides various transformation traits for use on iterators.
Provides C++20 additions to the <iterator> header.
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
typename iter_pointer< it_t >::type iter_pointer_t
Return the pointer type of the input type (transformation_trait shortcut).
Definition: iterator_traits.hpp:270
typename std::iterator_traits< it_t >::iterator_category iterator_category_tag_t
Exposes the iterator_category from the modelled concept.
Definition: iterator_traits.hpp:200
The SeqAn namespace for views.
Definition: async_input_buffer.hpp:343
SeqAn specific customisations in the standard namespace.
Additional non-standard concepts for ranges.
Adaptations of concepts from the standard library.
Auxiliary header for the views submodule .
Adaptations of concepts from the Ranges TS.
Provides seqan3::semiregular_box.
View adaptor definition for views::take_until and views::take_until_or_throw.
Definition: take_until.hpp:504
constexpr auto operator()(fun_t &&fun) const
Store the arguments and return a range adaptor closure object.
Definition: take_until.hpp:507
constexpr auto operator()(urng_t &&urange, fun_t &&fun) const
Call the view's constructor with the given parameters.
Definition: take_until.hpp:520
Provides C++20 additions to the type_traits header.