Yes, it can be easily done:
#include
#include
template
struct function_ripper {
static constexpr size_t n_args = sizeof...(ARGS);
};
template
auto constexpr make_ripper(R (ARGS...) ) {
return function_ripper();
}
void foo(int, double, const char*);
void check_args() {
constexpr size_t foo_args = decltype(make_ripper(foo))::n_args;
std::cout << "Foo has " << foo_args << " arguments.\n";
}