37 constexpr auto operator()(ptrdiff_t begin_pos, ptrdiff_t end_pos)
const noexcept
45 template <std::ranges::viewable_range urng_t>
47 std::ranges::range_difference_t<urng_t> begin_pos,
48 std::ranges::range_difference_t<urng_t> end_pos)
const
50 using position_t = std::ranges::range_difference_t<urng_t>;
51 if constexpr (std::ranges::sized_range<urng_t>)
55 begin_pos =
std::min(begin_pos, urange_size);
56 end_pos =
std::min(end_pos, urange_size);
58 position_t target_size = end_pos - begin_pos;
60 if (end_pos < begin_pos)
61 throw std::invalid_argument{
"end_pos argument to seqan3::views::slice must be >= the begin_pos argument."};
66#if SEQAN3_WORKAROUND_GCC_100139
70 return urange.substr(begin_pos,
static_cast<size_t>(target_size));
73 else if constexpr (is_type_specialisation_of_v<std::remove_cvref_t<urng_t>,
std::basic_string>
74 && std::is_const_v<std::remove_reference_t<urng_t>>)
79 else if constexpr (std::ranges::borrowed_range<urng_t> && std::ranges::contiguous_range<urng_t>
80 && std::ranges::sized_range<urng_t>)
82 return std::span{std::ranges::data(urange) + begin_pos,
static_cast<size_t>(target_size)};
85 else if constexpr (std::ranges::borrowed_range<urng_t> && std::ranges::random_access_range<urng_t>
86 && std::ranges::sized_range<urng_t>)
88 return std::ranges::subrange<std::ranges::iterator_t<urng_t>, std::ranges::iterator_t<urng_t>>{
89 std::ranges::begin(urange) + begin_pos,
90 std::ranges::begin(urange) + end_pos,
91 static_cast<size_t>(target_size)};
Provides seqan3::detail::adaptor_from_functor.
Template for range adaptor closure objects that store arguments and wrap a proto-adaptor.
Definition: adaptor_from_functor.hpp:57
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:377
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:395
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:146
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition: slice.hpp:178
constexpr auto type_reduce
A view adaptor that behaves like std::views::all, but type erases certain ranges.
Definition: type_reduce.hpp:150
Provides exceptions used in the I/O module.
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
The SeqAn namespace for views.
Definition: char_strictly_to.hpp:22
The <ranges> header from C++20's standard library.
View adaptor definition for views::slice.
Definition: slice.hpp:35
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:37
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:46
Provides seqan3::views::type_reduce.