The answer to this question picks apart a function type using a class template:
template <typename T>
struct function_args {};
template <typename R, typename... Args>
struct function_args<R(Args...)> {
using type = tuple<Args...>;
};
template <typename T>
using decltypeargs = typename function_args<T>::type;
As I studied what was being done here I tried to rewrite function_args
. I attempted to do this using a function so as to eliminate the need for the decltypeargs
template. But found myself mired in improper syntax:
template <typename T>
tuple<> myTry();
template <typename Ret, typename... Args>
tuple<Args...> myTry<Ret(Args...)>();
My hope had been to call decltype(myTry<decltype(foo)>())
to get the tuple
type instead of having to call decltypeargs<decltype(foo)>
. Is there a way to do this with a function declaration?
myTry()
is just more typing than not using it - what's the problem you're trying to solve? – Maltreat