FunctionInfo.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include "Utilities/TMPL.hpp"
7 
8 namespace tt {
9 namespace detail {
10 template <typename T>
11 struct function_info_impl;
12 
13 template <typename Ret, typename... Args>
14 struct function_info_impl<Ret(Args...)> {
15  using return_type = Ret;
16  using argument_types = tmpl::list<Args...>;
17  using class_type = void;
18 };
19 
20 template <typename Ret, typename... Args>
21 struct function_info_impl<Ret (*)(Args...)> {
22  using return_type = Ret;
23  using argument_types = tmpl::list<Args...>;
24  using class_type = void;
25 };
26 
27 template <typename Ret, typename... Args>
28 struct function_info_impl<Ret (*const)(Args...)> {
29  using return_type = Ret;
30  using argument_types = tmpl::list<Args...>;
31  using class_type = void;
32 };
33 
34 template <typename Ret, typename... Args>
35 struct function_info_impl<Ret (*const volatile)(Args...)> {
36  using return_type = Ret;
37  using argument_types = tmpl::list<Args...>;
38  using class_type = void;
39 };
40 
41 template <typename Ret, typename... Args>
42 struct function_info_impl<Ret (*volatile)(Args...)> {
43  using return_type = Ret;
44  using argument_types = tmpl::list<Args...>;
45  using class_type = void;
46 };
47 
48 template <typename Ret, typename Class, typename... Args>
49 struct function_info_impl<Ret (Class::*)(Args...)> {
50  using return_type = Ret;
51  using argument_types = tmpl::list<Args...>;
52  using class_type = Class;
53 };
54 
55 template <typename Ret, typename Class, typename... Args>
56 struct function_info_impl<Ret (Class::*)(Args...) const> {
57  using return_type = Ret;
58  using argument_types = tmpl::list<Args...>;
59  using class_type = Class;
60 };
61 
62 template <typename Ret, typename Class, typename... Args>
63 struct function_info_impl<Ret (Class::*)(Args...) const volatile> {
64  using return_type = Ret;
65  using argument_types = tmpl::list<Args...>;
66  using class_type = Class;
67 };
68 
69 template <typename Ret, typename Class, typename... Args>
70 struct function_info_impl<Ret (Class::*)(Args...) volatile> {
71  using return_type = Ret;
72  using argument_types = tmpl::list<Args...>;
73  using class_type = Class;
74 };
75 } // namespace detail
76 
77 /*!
78  * \ingroup TypeTraitsGroup
79  * \brief Returns a struct that contains the return type, argument types, and
80  * the class type if the `F` is a non-static member function
81  *
82  * The return class has member type aliases:
83  * - `return_type` The return type of the function
84  * - `argument_types` A `tmpl::list` of the arguments types of the function
85  * - `class_type` The type of the class if the function is a non-static member
86  * function, otherwise `void`
87  *
88  * \note For static member variables the class will be `void` because they are
89  * effectively free functions.
90  */
91 template <typename F>
92 using function_info = detail::function_info_impl<F>;
93 } // namespace tt
A collection of useful type traits.
Definition: TensorExpression.hpp:113
Definition: Determinant.hpp:11
Wraps the template metaprogramming library used (brigand)
detail::function_info_impl< F > function_info
Returns a struct that contains the return type, argument types, and the class type if the F is a non-...
Definition: FunctionInfo.hpp:92