Skip to content

Instantly share code, notes, and snippets.

@sithhell
Created September 8, 2017 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sithhell/482d797179ee0875cae56ff69b79db91 to your computer and use it in GitHub Desktop.
Save sithhell/482d797179ee0875cae56ff69b79db91 to your computer and use it in GitHub Desktop.
[11:36:19]:heller@shoeshine:/home/heller/tmp:0:$ cat args.cpp
#include <tuple>
template <typename Sig>
struct args;
template <typename R, typename...Args>
struct args<R(*)(Args...)>
{
typedef R result;
typedef std::tuple<Args...> args_tuple;
};
template <typename R, typename C, typename...Args>
struct args<R(C::*)(Args...)>
{
typedef R result;
typedef std::tuple<Args...> args_tuple;
};
void e(int, float);
double f(int, float);
struct s
{
void g(float);
};
#include <iostream>
#include <typeinfo>
int main()
{
std::cout
<< typeid(args<decltype(&e)>::args_tuple).name() << "\n"
<< typeid(args<decltype(&f)>::args_tuple).name() << "\n"
<< typeid(args<decltype(&s::g)>::args_tuple).name() << "\n"
;
}
[11:36:24]:heller@shoeshine:/home/heller/tmp:0:$ g++ -std=c++11 args.cpp && ./a.out | c++filt -t
std::tuple<int, float>
std::tuple<int, float>
std::tuple<float>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment