SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
adaptor_from_functor.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, 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 
14 #pragma once
15 
17 
18 namespace seqan3::detail
19 {
20 
21 // ============================================================================
22 // adaptor_from_functor
23 // ============================================================================
24 
55 template <typename functor_type, typename ...stored_args_ts>
56 class adaptor_from_functor :
57  public adaptor_base<adaptor_from_functor<functor_type, stored_args_ts...>, stored_args_ts...>
58 {
59 private:
61  using base_type = adaptor_base<adaptor_from_functor<functor_type, stored_args_ts...>, stored_args_ts...>;
62 
64  friend base_type;
65 
67  functor_type fun;
68 
76  template <std::ranges::input_range urng_t>
77  constexpr auto impl(urng_t && urange, stored_args_ts ... args) const
78  {
79  return fun(std::forward<urng_t>(urange), std::forward<stored_args_ts>(args)...);
80  }
81 
82 public:
86  constexpr adaptor_from_functor() = default;
87  constexpr adaptor_from_functor(adaptor_from_functor const &) noexcept = default;
88  constexpr adaptor_from_functor(adaptor_from_functor &&) noexcept = default;
89  constexpr adaptor_from_functor & operator=(adaptor_from_functor const &) noexcept = default;
90  constexpr adaptor_from_functor & operator=(adaptor_from_functor &&) noexcept = default;
91  ~adaptor_from_functor() noexcept = default;
92 
94  constexpr adaptor_from_functor(functor_type f, stored_args_ts ... args) :
95  base_type{std::forward<stored_args_ts>(args)...}, fun{std::move(f)}
96  {}
98 };
99 
100 } // namespace seqan3::detail
Provides seqan3::detail::adaptor_base and seqan3::detail::combined_adaptor.
auto const move
A view that turns lvalue-references into rvalue-references.
Definition: move.hpp:74