22namespace bio::ranges::detail
35 template <
typename irange_t>
39 std::views::all_t<irange_t> irange;
44 template <
typename urng_t>
45 constexpr auto operator()(urng_t && urange,
size_t const i)
const
47 std::ranges::range_reference_t<
decltype(
std::as_const(irange))>>
49 size_t const div = i / (step_size + std::ranges::size(irange));
50 size_t const rest = i % (step_size + std::ranges::size(irange));
51 return (rest < step_size) ? urange[i -
div * std::ranges::size(irange)] : irange[rest - step_size];
57 template <std::ranges::forward_range inserted_rng_t>
58 constexpr auto operator()(
size_t const size, inserted_rng_t && i)
const noexcept
60 return detail::adaptor_from_functor{*
this,
size, std::views::all(std::forward<inserted_rng_t>(i))};
69 template <std::ranges::range urng_t, std::ranges::range inserted_rng_t>
70 constexpr auto operator()(urng_t && urange,
size_t const step_size, inserted_rng_t && irange)
const noexcept
72 static_assert(std::ranges::random_access_range<urng_t>,
73 "The underlying range parameter in views::interleave must model "
74 "std::ranges::random_access_range.");
75 static_assert(std::ranges::viewable_range<urng_t>,
76 "The underlying range parameter in views::interleave must model std::ranges::viewable_range.");
77 static_assert(std::ranges::sized_range<urng_t>,
78 "The underlying range parameter in views::interleave must model std::ranges::sized_range.");
80 static_assert(std::ranges::random_access_range<inserted_rng_t>,
81 "The range to be inserted by views::interleave must model std::ranges::forward_range.");
82 static_assert(std::ranges::sized_range<inserted_rng_t>,
83 "The range to be inserted by views::interleave must model std::ranges::sized_range.");
85 static_assert(std::common_reference_with<std::ranges::range_reference_t<urng_t>,
86 std::ranges::range_reference_t<inserted_rng_t const>>,
87 "The underlying range and the CONST inserted range must have reference types that have a "
88 "common_reference type.");
91 std::ranges::size(urange) +
92 (((std::ranges::size(urange) / step_size) - (std::ranges::size(urange) % step_size == 0 ? 1 : 0)) *
93 std::ranges::size(irange));
95 func<std::views::all_t<inserted_rng_t>> fn{.irange = std::views::all(std::forward<inserted_rng_t>(irange)),
96 .step_size = step_size};
98 return view_transform_by_pos{std::forward<urng_t>(urange), std::move(fn),
size};
constexpr auto size
A type trait that holds the size of a (semi-)alphabet.
Definition: concept.hpp:517
constexpr auto interleave
A view that interleaves a given range into another range at regular intervals.
Definition: interleave.hpp:164
The BioC++ namespace for views.