Consider the following code:
template <class... Args>
struct function_arguments
{
using tuple = std::tuple<Args...>;
};
template <class>
struct function_traits
: function_arguments<>
{};
template <class R, class... Args>
struct type<R(Args...)>
: function_arguments<Args...>
{};
template <class R, class... Args>
struct type<R(Args... ...)>
: function_arguments<Args...>
{};
and the following function declarations:
int f(int x, int y, int z);
int g(int x, int y, int z, ...);
Without problem function_traits<decltype(f())>::tuple will return a tuple with all the argument types in it. Is there a way to do the same thing for a C99 variadic function (extracting Args... + C99 variadic types and put everything together in a tuple)? If so, how?c
Aucun commentaire:
Enregistrer un commentaire