SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
function.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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 // ----------------------------------------------------------------------------
22 // function_traits
23 // ----------------------------------------------------------------------------
24 
26 template <typename function_t>
27 struct function_traits;
29 
47 template <typename return_t, typename ...args_t>
48 struct function_traits<std::function<return_t(args_t...)>>
49 {
51  static constexpr size_t argument_count = sizeof...(args_t);
52 
54  using result_type = return_t;
55 
59  template <size_t index>
61  requires (index < argument_count)
63  using argument_type_at = pack_traits::at<index, args_t...>;
64 };
65 
67 // Overload for all function types.
68 template <typename function_t>
69  requires requires (function_t fn) { {std::function{fn}}; }
70 struct function_traits<function_t> : function_traits<decltype(std::function{std::declval<function_t>()})>
71 {};
73 } // namespace seqan3
74 
75 namespace seqan3::detail
76 {
77 // ----------------------------------------------------------------------------
78 // multi_invocable
79 // ----------------------------------------------------------------------------
80 
85 template <typename ...invocable_ts>
86 struct multi_invocable : invocable_ts...
87 {
89  using invocable_ts::operator()...;
90 };
91 
93 template <typename ...invocable_ts>
94 multi_invocable(invocable_ts...) -> multi_invocable<invocable_ts...>;
95 
96 } // namespace seqan3::detail
seqan3::function_traits< std::function< return_t(args_t...)> >::result_type
return_t result_type
The return type of the function target.
Definition: function.hpp:54
functional
std::function
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
std
SeqAn specific customisations in the standard namespace.
traits.hpp
Provides traits for seqan3::type_list.
seqan3::pack_traits::at
typename decltype(detail::at< idx, pack_t... >())::type at
Return the type at given index from the type pack.
Definition: traits.hpp:221
seqan3::function_traits< std::function< return_t(args_t...)> >::argument_type_at
pack_traits::at< index, args_t... > argument_type_at
The argument type at the given index.
Definition: function.hpp:63