SeqAn3  3.1.0-rc.1
The Modern C++ library for sequence analysis.
function_traits.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 
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>
58  requires (index < argument_count)
60  using argument_type_at = pack_traits::at<index, args_t...>;
61 };
62 
64 // Overload for all function types.
65 template <typename function_t>
66  requires requires (function_t fn) { {std::function{fn}}; }
67 struct function_traits<function_t> : function_traits<decltype(std::function{std::declval<function_t>()})>
68 {};
70 
71 } // namespace seqan3
typename decltype(detail::at< idx >(list_t{}))::type at
Return the type at given index from the type list.
Definition: traits.hpp:260
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
SeqAn specific customisations in the standard namespace.
return_t result_type
The return type of the function target.
Definition: function_traits.hpp:51
pack_traits::at< index, args_t... > argument_type_at
The argument type at the given index.
Definition: function_traits.hpp:60
Provides various traits for template packs.