26namespace seqan3::detail
37 constexpr auto operator()(ptrdiff_t begin_pos, ptrdiff_t end_pos)
const noexcept
39 return detail::adaptor_from_functor{*
this, begin_pos, end_pos};
45 template <std::ranges::viewable_range urng_t>
46 constexpr auto operator()(urng_t && urange,
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> &&
80 std::ranges::contiguous_range<urng_t> &&
81 std::ranges::sized_range<urng_t>)
83 return std::span{std::ranges::data(urange) + begin_pos,
static_cast<size_t>(target_size)};
86 else if constexpr (std::ranges::borrowed_range<urng_t> &&
87 std::ranges::random_access_range<urng_t> &&
88 std::ranges::sized_range<urng_t>)
90 return std::ranges::subrange<std::ranges::iterator_t<urng_t>, std::ranges::iterator_t<urng_t>>
94 static_cast<size_t>(target_size)
183inline constexpr auto slice = detail::slice_fn{};
Provides seqan3::detail::adaptor_from_functor.
The <concepts> header from C++20's standard library.
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:368
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:388
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:151
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition: slice.hpp:183
constexpr auto type_reduce
A view adaptor that behaves like std::views::all, but type erases certain ranges.
Definition: type_reduce.hpp:153
Provides exceptions used in the I/O module.
The <iterator> header from C++20's standard library.
The SeqAn namespace for views.
Definition: char_to.hpp:22
The <ranges> header from C++20's standard library.
Provides std::span from the C++20 standard library.
Provides seqan3::views::type_reduce.
The <type_traits> header from C++20's standard library.