SeqAn3 3.3.0-rc.1
The Modern C++ library for sequence analysis.
 
Loading...
Searching...
No Matches
adaptor_from_functor.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
13#pragma once
14
16
17namespace seqan3::detail
18{
19
20// ============================================================================
21// adaptor_from_functor
22// ============================================================================
23
54template <typename functor_type, typename... stored_args_ts>
56 public adaptor_base<adaptor_from_functor<functor_type, stored_args_ts...>, stored_args_ts...>
57{
58private:
60 using base_type = adaptor_base<adaptor_from_functor<functor_type, stored_args_ts...>, stored_args_ts...>;
61
63 friend base_type;
64
66 functor_type fun;
67
75 template <std::ranges::input_range urng_t>
76 constexpr auto impl(urng_t && urange, stored_args_ts... args) const
77 {
78 return fun(std::forward<urng_t>(urange), std::forward<stored_args_ts>(args)...);
79 }
80
81public:
85 constexpr adaptor_from_functor() = default;
86 constexpr adaptor_from_functor(adaptor_from_functor const &) noexcept = default;
87 constexpr adaptor_from_functor(adaptor_from_functor &&) noexcept = default;
88 constexpr adaptor_from_functor & operator=(adaptor_from_functor const &) noexcept = default;
89 constexpr adaptor_from_functor & operator=(adaptor_from_functor &&) noexcept = default;
90 ~adaptor_from_functor() noexcept = default;
91
93 constexpr adaptor_from_functor(functor_type f, stored_args_ts... args) :
94 base_type{std::forward<stored_args_ts>(args)...},
95 fun{std::move(f)}
96 {}
98};
99
100} // namespace seqan3::detail
Provides seqan3::detail::adaptor_base and seqan3::detail::combined_adaptor.
CRTP-base to simplify the definition of range adaptor closure objects and similar types.
Definition: adaptor_base.hpp:77
Template for range adaptor closure objects that store arguments and wrap a proto-adaptor.
Definition: adaptor_from_functor.hpp:57
functor_type fun
The stored functor, usually a "proto-adaptor".
Definition: adaptor_from_functor.hpp:66
friend base_type
Befriend the base class so it can call impl().
Definition: adaptor_from_functor.hpp:63
constexpr adaptor_from_functor(adaptor_from_functor const &) noexcept=default
Defaulted.
constexpr adaptor_from_functor()=default
Defaulted.
constexpr adaptor_from_functor(adaptor_from_functor &&) noexcept=default
Defaulted.
constexpr auto impl(urng_t &&urange, stored_args_ts... args) const
Delegate the range argument and stored arguments to the wrapped functor.
Definition: adaptor_from_functor.hpp:76
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29