SeqAn3 3.4.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// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
13
14namespace seqan3::detail
15{
16
17// ============================================================================
18// adaptor_from_functor
19// ============================================================================
20
51template <typename functor_type, typename... stored_args_ts>
53 public adaptor_base<adaptor_from_functor<functor_type, stored_args_ts...>, stored_args_ts...>
54{
55private:
57 using base_type = adaptor_base<adaptor_from_functor<functor_type, stored_args_ts...>, stored_args_ts...>;
58
60 friend base_type;
61
63 functor_type fun;
64
72 template <std::ranges::input_range urng_t>
73 constexpr auto impl(urng_t && urange, stored_args_ts... args) const
74 {
75 return fun(std::forward<urng_t>(urange), std::forward<stored_args_ts>(args)...);
76 }
77
78public:
82 constexpr adaptor_from_functor() = default;
83 constexpr adaptor_from_functor(adaptor_from_functor const &) noexcept = default;
84 constexpr adaptor_from_functor(adaptor_from_functor &&) noexcept = default;
85 constexpr adaptor_from_functor & operator=(adaptor_from_functor const &) noexcept = default;
86 constexpr adaptor_from_functor & operator=(adaptor_from_functor &&) noexcept = default;
87 ~adaptor_from_functor() noexcept = default;
88
90 constexpr adaptor_from_functor(functor_type f, stored_args_ts... args) :
91 base_type{std::forward<stored_args_ts>(args)...},
92 fun{std::move(f)}
93 {}
95};
96
97} // 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:74
Template for range adaptor closure objects that store arguments and wrap a proto-adaptor.
Definition adaptor_from_functor.hpp:54
functor_type fun
The stored functor, usually a "proto-adaptor".
Definition adaptor_from_functor.hpp:63
friend base_type
Befriend the base class so it can call impl().
Definition adaptor_from_functor.hpp:60
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:73
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Hide me