A wrapper type around an existing view adaptor that enables "deep view" behaviour for that view.
More...
|
constexpr auto | operator() () const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
|
template<typename first_arg_t , typename ... stored_arg_types> |
constexpr auto | operator() (first_arg_t &&first, stored_arg_types &&...args) const |
| Called to produce a range adaptor closure object if the wrapped functor was not a range adaptor closure object before, i.e. requires arguments. More...
|
|
template<std::ranges::input_range urng_t> |
constexpr auto | operator() (urng_t &&urange) && |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
|
template<std::ranges::input_range urng_t> |
constexpr auto | operator() (urng_t &&urange) const & |
| Specialisation of the range-handling operator() for range-of-range (this is where deep changes the behaviour for nested ranges). More...
|
|
template<std::ranges::input_range urng_t, typename ... stored_arg_types> |
constexpr auto | operator() (urng_t &&urange, stored_arg_types &&...args) const |
| Called to produce a range if the wrapped functor was not a range adaptor closure object before but necessary arguments are also provided. More...
|
|
constexpr auto | pass_args_to_impl (urng_t &&urange, std::index_sequence< Is... > const &) && |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
|
constexpr auto | pass_args_to_impl (urng_t &&urange, std::index_sequence< Is... > const &) const & |
| Helper function to unpack the tuple and delegate to the derived type.
|
|
template<typename underlying_adaptor_t>
class seqan3::views::deep< underlying_adaptor_t >
A wrapper type around an existing view adaptor that enables "deep view" behaviour for that view.
- Template Parameters
-
underlying_adaptor_t | The type of the adaptor being wrapped. |
Deep views
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. seqan3::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, seqan3::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.
View properties
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 |
seqan3::const_iterable_range | | preserved |
| | |
std::ranges::range_reference_t | std::ranges::input_range | std::ranges::input_range + std::ranges::view |
Examples
Wrapping an adaptor that takes no parameters ("range adaptor <i>closure</i> object"):
namespace my
{
}
int main()
{
using seqan3::operator""_dna5;
auto r = foo | std::views::reverse;
auto e = foo | my::deep_reverse;
}
A wrapper type around an existing view adaptor that enables "deep view" behaviour for that view.
Definition: deep.hpp:102
Provides seqan3::views::deep.
Provides seqan3::dna5, container aliases and string literals.
Adaptations of concepts from the Ranges TS.
Wrapping an adaptor that takes parameters:
namespace my
{
}
int main()
{
using seqan3::operator""_dna5;
auto e = foo | my::deep_take(1);
}
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
constexpr auto take
A view adaptor that returns the first size elements from the underlying range (or less if the underly...
Definition: take.hpp:611
Provides seqan3::views::take.
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.
- Attention
- Note that in the case of parameter handling the arguments to views::deep are copied to each invocation of the underlying adaptor if they are temporaries. This is no problem for small objects like the integer above, but might be expensive for larger ones. To avoid this, pass in references to external objects instead of temporaries:
namespace my
{
}
int main()
{
using seqan3::operator""_dna5;
int i = 3;
auto f = foo | my::deep_take(i);
}
Wrapping an adaptor including its arguments:
namespace my
{
}
int main()
{
using seqan3::operator""_dna5;
auto e = foo | my::deep_take1;
}
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.