mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
98 lines
3.3 KiB
Plaintext
98 lines
3.3 KiB
Plaintext
function_traits
|
|
|
|
Allows the traits of functions to be determined.
|
|
|
|
template <typename T>
|
|
struct function_traits;
|
|
|
|
template <typename TReturn, typename... TArgs>
|
|
struct function_traits<TReturn(*)(TArgs...)>
|
|
____________________________________________________________________________________________________
|
|
Member types
|
|
|
|
function_type
|
|
The signature of the function.
|
|
TReturn(TArgs...)
|
|
____________________________________________________________________________________________________
|
|
return_type
|
|
The return type.
|
|
TReturn
|
|
____________________________________________________________________________________________________
|
|
object_type
|
|
The object type, if a member function.
|
|
Otherwise void.
|
|
____________________________________________________________________________________________________
|
|
argument_types
|
|
An etl::type_list of the arguments.
|
|
etl::type_list<TArgs...>
|
|
____________________________________________________________________________________________________
|
|
is_function
|
|
true if a free or static member function.
|
|
bool
|
|
____________________________________________________________________________________________________
|
|
is_member_function
|
|
true if a member function.
|
|
bool
|
|
____________________________________________________________________________________________________
|
|
is_const
|
|
true if a const member function.
|
|
bool
|
|
____________________________________________________________________________________________________
|
|
argument_count
|
|
The number of arguments.
|
|
size_t
|
|
____________________________________________________________________________________________________
|
|
Example
|
|
|
|
int free_int(int i, int j);
|
|
|
|
class Object
|
|
{
|
|
public:
|
|
int member_int(int i, int j);
|
|
int member_int_const(int i, int j) const;
|
|
static void member_static(int i, int j);
|
|
};
|
|
____________________________________________________________________________________________________
|
|
using traits1 = etl::function_traits<decltype(&free_int)>;
|
|
function_type int(int, int)
|
|
return_type int
|
|
object_type void
|
|
argument_types etl::type_list<int, int>
|
|
is_function true
|
|
is_member_function false
|
|
is_const false
|
|
argument_count 2
|
|
____________________________________________________________________________________________________
|
|
using traits2 = etl::function_traits<decltype(&Object::member_int)>;
|
|
function_type int(int, int)
|
|
return_type int
|
|
object_type Object
|
|
argument_types etl::type_list<int, int>
|
|
is_function false
|
|
is_member_function true
|
|
is_const false
|
|
argument_count 2
|
|
____________________________________________________________________________________________________
|
|
using traits3 = etl::function_traits<decltype(&Object::member_int_const)>;
|
|
function_type int(int, int) const
|
|
return_type int
|
|
object_type Object
|
|
argument_types etl::type_list<int, int>
|
|
is_function false
|
|
is_member_function true
|
|
is_const true
|
|
argument_count 2
|
|
____________________________________________________________________________________________________
|
|
using traits4 = etl::function_traits<decltype(&Object::member_static)>;
|
|
function_type void(int, int)
|
|
return_type void
|
|
object_type void
|
|
argument_types etl::type_list<int, int>
|
|
is_function true
|
|
is_member_function false
|
|
is_const false
|
|
argument_count 2
|
|
|
|
|