SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::detail::adaptor_base< derived_type, stored_args_ts > Class Template Reference

CRTP-base to simplify the definition of range adaptor closure objects and similar types. More...

#include <seqan3/core/range/detail/adaptor_base.hpp>

+ Inheritance diagram for seqan3::detail::adaptor_base< derived_type, stored_args_ts >:

Public Member Functions

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 &
 Function-style overload for ranges.
 
Constructors, destructor and assignment
constexpr adaptor_base (adaptor_base const &) noexcept=default
 Defaulted.
 
constexpr adaptor_base (adaptor_base &&) noexcept=default
 Defaulted.
 
constexpr adaptor_baseoperator= (adaptor_base const &) noexcept=default
 Defaulted.
 
constexpr adaptor_baseoperator= (adaptor_base &&) noexcept=default
 Defaulted.
 
 ~adaptor_base () noexcept=default
 Defaulted.
 
constexpr adaptor_base (stored_args_ts... args) noexcept(noexcept(std::tuple< stored_args_ts... >{ std::forward< stored_args_ts >(args)...}))
 Constructor with possible arguments; becomes a default constructor for adaptors without args.
 

Private Member Functions

template<typename urng_t , size_t... Is>
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.
 
template<typename urng_t , size_t... Is>
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.
 

Private Attributes

std::tuple< stored_args_ts... > arguments
 Stores the arguments.
 
friend derived_type
 Befriend the derived_type so it can access private members if need be.
 

Friends

template<typename arg_t >
constexpr friend auto operator| (adaptor_base &&me, arg_t &&arg)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename arg_t >
constexpr friend auto operator| (adaptor_base const &me, arg_t &&arg)
 Right-hand-side pipe operator that handles composing.
 
template<typename arg_t >
constexpr friend auto operator| (arg_t &&arg, derived_type &&me)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename arg_t >
constexpr friend auto operator| (arg_t &&arg, derived_type const &me)
 Left-hand-side pipe operator that handles range input or composing.
 

Detailed Description

template<typename derived_type, typename... stored_args_ts>
class seqan3::detail::adaptor_base< derived_type, stored_args_ts >

CRTP-base to simplify the definition of range adaptor closure objects and similar types.

Template Parameters
derived_typeCRTP specialisation parameter.
stored_args_tsSome closure objects store values, these are their types.

See How to write a view for details on what range adaptor closure objects are.

This class requires from the derived_type:

  • an impl() function that takes a range and possibly further arguments.

This base class provides:

  • Storage of args, including perfect forwarding and moving-out.
  • operator() that takes a range and passes the range and stored args to the derived_type.
  • operator| that also takes a range and passes the range and stored args to the derived_type.
  • operator| that takes another adaptor and returns seqan3::detail::combined_adaptor

Examples

"Direct derivation"

From include/seqan3/search/views/kmer_hash.hpp:

{
constexpr auto operator()(shape const & shape_) const
{
return adaptor_from_functor{*this, shape_};
}
template <std::ranges::range urng_t>
constexpr auto operator()(urng_t && urange, shape const & shape_) const
{
static_assert(std::ranges::viewable_range<urng_t>,
"The range parameter to views::kmer_hash cannot be a temporary of a non-view range.");
static_assert(std::ranges::forward_range<urng_t>,
"The range parameter to views::kmer_hash must model std::ranges::forward_range.");
"The range parameter to views::kmer_hash must be over elements of seqan3::semialphabet.");
return kmer_hash_view{std::forward<urng_t>(urange), shape_};
}
};
Template for range adaptor closure objects that store arguments and wrap a proto-adaptor.
Definition adaptor_from_functor.hpp:54
A class that defines which positions of a pattern to hash.
Definition shape.hpp:57
The basis for seqan3::alphabet, but requires only rank interface (not char).
views::kmer_hash's range adaptor object type (non-closure).
Definition kmer_hash.hpp:685

This adaptor directly derives from adaptor_base (instead of just using seqan3::detail::adaptor_for_view_without_args) so that it can decide between actually calling the respective view's constructor and delegating to a different view (in this case std::views::all) based on the type of input.

Derived templates

Friends And Related Symbol Documentation

◆ operator| [1/2]

template<typename derived_type , typename... stored_args_ts>
template<typename arg_t >
constexpr friend auto operator| ( adaptor_base< derived_type, stored_args_ts > const &  me,
arg_t &&  arg 
)
friend

Right-hand-side pipe operator that handles composing.

Template Parameters
arg_tRHS argument type.
Parameters
[in]meLHS, another adaptor.
[in]argRHS.

This operator assumes that the RHS is another range adaptor closure object and it returns a seqan3::detail::combined_adaptor that wraps that adaptor and this one.

Note that this operator takes adaptor_base and not derived_type as parameter type so that an implicit conversion is required for invoking this function. This prioritises the LHS-pipe-operator overload and resolves ambiguity in cases where they are competing. It has no semantic meaning, the type is down-cast inside the function again.

◆ operator| [2/2]

template<typename derived_type , typename... stored_args_ts>
template<typename arg_t >
constexpr friend auto operator| ( arg_t &&  arg,
derived_type const &  me 
)
friend

Left-hand-side pipe operator that handles range input or composing.

Template Parameters
arg_tLHS argument type.
Parameters
[in]argLHS, either a range or another adaptor.
[in]meRHS.

If the LHS models std::ranges::input_range this functions delegates to operator() otherwise it assumes the LHS is another range adaptor closure object and it returns a seqan3::detail::combined_adaptor that wraps that adaptor and this one.


The documentation for this class was generated from the following file:
Hide me