gogoWebsite

c++11's function_traits

Updated to 13 hours ago

function_traits

Example: int func(int a, string b);

function_traits<decltype(func)>::function_type; //Get function type int _cdecl(int, string) This is a bit similar to typeid().name()!

function_traits<decltype(func)>::return_type; //int

function_traits<decltype(func)>::arity; //2

function_traits<decltype(func)>::arg_type<0>; // Get the first parameter type of the function int

function_traits<decltype(func)>::arg_type<1>; // Get the second parameter type of the function string