40 constexpr
auto operator()(ptrdiff_t begin_pos, ptrdiff_t end_pos)
const noexcept
48 template <std::ranges::viewable_range urng_t>
50 std::ranges::range_difference_t<urng_t> begin_pos,
51 std::ranges::range_difference_t<urng_t> end_pos)
const
53 using position_t = std::ranges::range_difference_t<urng_t>;
54 if constexpr (std::ranges::sized_range<urng_t>)
58 begin_pos =
std::min(begin_pos, urange_size);
59 end_pos =
std::min(end_pos, urange_size);
61 position_t target_size = end_pos - begin_pos;
63 if (end_pos < begin_pos)
64 throw std::invalid_argument{
"end_pos argument to seqan3::views::slice must be >= the begin_pos argument."};
69 #if SEQAN3_WORKAROUND_GCC_100139
73 return urange.substr(begin_pos,
static_cast<size_t>(target_size));
82 else if constexpr (std::ranges::borrowed_range<urng_t> &&
83 std::ranges::contiguous_range<urng_t> &&
84 std::ranges::sized_range<urng_t>)
86 return std::span{std::ranges::data(urange) + begin_pos,
static_cast<size_t>(target_size)};
89 else if constexpr (std::ranges::borrowed_range<urng_t> &&
90 std::ranges::random_access_range<urng_t> &&
91 std::ranges::sized_range<urng_t>)
93 return std::ranges::subrange<std::ranges::iterator_t<urng_t>, std::ranges::iterator_t<urng_t>>
95 std::ranges::begin(urange) + begin_pos,
96 std::ranges::begin(urange) + end_pos,
97 static_cast<size_t>(target_size)
Template for range adaptor closure objects that store arguments and wrap a proto-adaptor.
Definition: detail.hpp:371
Provides seqan3::views::drop.
typename decltype(detail::split_after< i >(list_t{}))::first_type take
Return a seqan3::type_list of the first n types in the input type list.
Definition: traits.hpp:331
typename decltype(detail::split_after< i >(list_t{}))::second_type drop
Return a seqan3::type_list of the types in the input type list, except the first n.
Definition: traits.hpp:351
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:150
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition: slice.hpp:191
constexpr auto type_reduce
A view adaptor that behaves like std::views::all, but type erases certain ranges.
Definition: type_reduce.hpp:158
Provides exceptions used in the I/O module.
Provides C++20 additions to the <iterator> header.
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
The SeqAn namespace for views.
Definition: char_to.hpp:22
Additional non-standard concepts for ranges.
Auxiliary header for the views submodule .
Adaptations of concepts from the Ranges TS.
Provides std::span from the C++20 standard library.
View adaptor definition for views::slice.
Definition: slice.hpp:38
constexpr auto operator()(ptrdiff_t begin_pos, ptrdiff_t end_pos) const noexcept
Store the arguments and return a range adaptor closure object.
Definition: slice.hpp:40
constexpr auto operator()(urng_t &&urange, std::ranges::range_difference_t< urng_t > begin_pos, std::ranges::range_difference_t< urng_t > end_pos) const
Call the view's constructor with the underlying view as argument.
Definition: slice.hpp:49
Provides seqan3::views::take.
Provides seqan3::views::type_reduce.
Provides C++20 additions to the type_traits header.