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

Template for range adaptor closure objects that store arguments and wrap a proto-adaptor. More...

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

+ Inheritance diagram for seqan3::detail::adaptor_from_functor< functor_type, stored_args_ts >:

Public Member Functions

Constructors, destructor and assignment
constexpr adaptor_from_functor ()=default
 Defaulted.
 
constexpr adaptor_from_functor (adaptor_from_functor const &) noexcept=default
 Defaulted.
 
constexpr adaptor_from_functor (adaptor_from_functor &&) noexcept=default
 Defaulted.
 
constexpr adaptor_from_functoroperator= (adaptor_from_functor const &) noexcept=default
 Defaulted.
 
constexpr adaptor_from_functoroperator= (adaptor_from_functor &&) noexcept=default
 Defaulted.
 
 ~adaptor_from_functor () noexcept=default
 Defaulted.
 
constexpr adaptor_from_functor (functor_type f, stored_args_ts... args)
 Construct from functor and possibly arguments.
 
- Public Member Functions inherited from seqan3::detail::adaptor_base< adaptor_from_functor< functor_type, stored_args_ts... >, stored_args_ts... >
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.
 
constexpr auto operator() (urng_t &&urange) const &
 Function-style overload for ranges.
 
constexpr adaptor_base (adaptor_base const &) noexcept=default
 Defaulted.
 
constexpr adaptor_base (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.
 
constexpr adaptor_baseoperator= (adaptor_base const &) noexcept=default
 Defaulted.
 
constexpr adaptor_baseoperator= (adaptor_base &&) noexcept=default
 Defaulted.
 
 ~adaptor_base () noexcept=default
 Defaulted.
 

Private Types

using base_type = adaptor_base< adaptor_from_functor< functor_type, stored_args_ts... >, stored_args_ts... >
 Type of the CRTP-base.
 

Private Member Functions

template<std::ranges::input_range urng_t>
constexpr auto impl (urng_t &&urange, stored_args_ts... args) const
 Delegate the range argument and stored arguments to the wrapped functor.
 

Private Attributes

friend base_type
 Befriend the base class so it can call impl().
 
functor_type fun
 The stored functor, usually a "proto-adaptor".
 

Detailed Description

template<typename functor_type, typename... stored_args_ts>
class seqan3::detail::adaptor_from_functor< functor_type, stored_args_ts >

Template for range adaptor closure objects that store arguments and wrap a proto-adaptor.

Template Parameters
functor_typeType of the proto-adaptor functor.
stored_args_tsTypes of the stored arguments.

This template is particularly useful in combination with range adaptor objects that are not closure objects (a.k.a. proto adaptors). These objects take other parameters in addition to the range parameter that they might need to store in which case they can return an object of this type with the stored arguments.

This template delegates back to the proto adaptor for handling range input (impl() calls operator() of the proto-adaptor).

Example

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 is the full proto-adaptor, first look at the second member function: it handles range and argument input and delegates to the view's constructor. In other, simpler cases you could invoke other adaptors here.

And it provides an operator() that takes only the argument and returns a range adaptor closure object with the argument wrapped (first member function). The proto-adaptor is passed to the closure object, as well, so that the proto-adaptor's operator() can be used for handling range input.

Note that the proto-adaptor does not provide operator|, this is only required of adaptor closure objects.

Member Function Documentation

◆ impl()

template<typename functor_type , typename... stored_args_ts>
template<std::ranges::input_range urng_t>
constexpr auto seqan3::detail::adaptor_from_functor< functor_type, stored_args_ts >::impl ( urng_t &&  urange,
stored_args_ts...  args 
) const
inlineconstexprprivate

Delegate the range argument and stored arguments to the wrapped functor.

Template Parameters
urng_tThe underlying range type.
stored_args_tsThe arguments to the view (this first one will be a range, the rest is optional).
Parameters
[in]urangeThe underling range.
[in]argsThe arguments to the constructor.
Returns
Whatever the wrapped functor returns, usually a view.

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