SeqAn3  3.2.0
The Modern C++ library for sequence analysis.
function_traits.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 
15 #include <functional>
16 
18 
19 namespace seqan3
20 {
21 
23 template <typename function_t>
24 struct function_traits;
26 
44 template <typename return_t, typename... args_t>
45 struct function_traits<std::function<return_t(args_t...)>>
46 {
48  static constexpr size_t argument_count = sizeof...(args_t);
49 
51  using result_type = return_t;
52 
56  template <size_t index>
57  requires (index < argument_count)
58  using argument_type_at = pack_traits::at<index, args_t...>;
59 };
60 
62 // Overload for all function types.
63 template <typename function_t>
64  requires requires (function_t fn) {
65  {
66  std::function{fn}
67  };
68  }
69 struct function_traits<function_t> : function_traits<decltype(std::function{std::declval<function_t>()})>
70 {};
72 
73 } // namespace seqan3
requires requires
The rank_type of the semi-alphabet; defined as the return type of seqan3::to_rank....
Definition: alphabet/concept.hpp:164
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
SeqAn specific customisations in the standard namespace.
requires(index< argument_count) using argument_type_at
The argument type at the given index.
return_t result_type
The return type of the function target.
Definition: function_traits.hpp:51
Provides various traits for template packs.