A wrapper type around an existing view adaptor that enables "deep view" behaviour for that view. More...
#include <bio/ranges/views/deep.hpp>
Public Member Functions | |
Constructors, destructor and assignment | |
constexpr | deep () noexcept=default |
Defaulted. | |
constexpr | deep (deep const &) noexcept=default |
Defaulted. | |
constexpr | deep (deep &&) noexcept=default |
Defaulted. | |
constexpr deep & | operator= (deep const &) noexcept=default |
Defaulted. | |
constexpr deep & | operator= (deep &&) noexcept=default |
Defaulted. | |
~deep () noexcept=default | |
Defaulted. | |
Related Functions | |
(Note that these are not member functions.) | |
Template argument deduction guides. | |
template<typename underlying_adaptor_t > | |
deep (underlying_adaptor_t &&inner) -> deep< underlying_adaptor_t > | |
Template argument deduction helper that preserves lvalue references and turns rvalue references into values. | |
A wrapper type around an existing view adaptor that enables "deep view" behaviour for that view.
underlying_adaptor_t | The type of the adaptor being wrapped. |
If you pass a range to a view that view performs some transformation on that range. If the range passed is multi-dimensional (i.e. a range-of-ranges) that transformation happens on the outermost range. So if you call std::views::reverse on a range-of-dna-ranges, it will revert the order of the dna-ranges, but leave the dna-ranges themselves unchanged.
In some cases this is not desirable or even possible, i.e. bio::views::complement performs it's operation on nucleotide-ranges and it would be logical to do so, even it is passed a range-of-nucleotide-ranges (it obviously cannot transform the outer range). We call these views "deep views" as they always perform their operation on the innermost ranges of a multi-dimensional range; in case the input is a one-dimensional range, deepness does not modify the behaviour.
Strictly speaking, bio::views::deep is a view adaptor adaptor, i.e. it gets passed another adaptor when being constructed (not via the pipe!) and returns an adaptor that behaves like the underlying one, except being deep.
You can use it mostly like any other view (adaptor) with some subtle differences, illustrated in the examples below.
The returned view has the same requirements and guarantees as those of the underlying adaptor type, except that it is also deep, i.e. if the underlying range is range-of-ranges, all transformations apply to the innermost ranges and conversely the requirements also apply to the innermost ranges of the underlying range and guarantees apply to the innermost ranges of the returned range.
For the higher dimensions (all except the innermost ranges) the following properties hold:
Concepts and traits | urng_t (underlying range type) | rrng_t (returned range type) |
---|---|---|
std::ranges::input_range | required | preserved |
std::ranges::forward_range | preserved | |
std::ranges::bidirectional_range | preserved | |
std::ranges::random_access_range | preserved | |
std::ranges::contiguous_range | lost | |
std::ranges::viewable_range | required | guaranteed |
std::ranges::view | guaranteed | |
std::ranges::sized_range | preserved | |
std::ranges::common_range | preserved | |
std::ranges::output_range | lost | |
bio::ranges::const_iterable_range | preserved | |
std::ranges::range_reference_t | std::ranges::input_range | std::ranges::input_range + std::ranges::view |
Wrapping an adaptor that takes no parameters ("range adaptor <i>closure</i> object"):
Wrapping an adaptor that takes parameters:
The above example illustrates that views::deep has two sets of arguments, the arguments to construct this adaptor, and the arguments passed to the underlying adaptor when calling this adaptor. You can use ()
for both, but we highly recommend to use {}
to not confuse these; or just use an alias.
Wrapping an adaptor including its arguments:
In the above example the argument to the underlying adaptor is hardcoded and can't be changed at the call-site. It is less flexible, but does not require workarounds for arguments that are expensive (or impossible) to copy.