Last active
October 10, 2016 07:55
-
-
Save Masstronaut/8b66b40fb0358e717093b9872ab7305b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template<typename Ret, typename... Args> | |
constexpr int arg_count(Ret(*)(Args...)){ | |
return sizeof...(Args); | |
} | |
void foo(int, float, double, char){} | |
int foo2(float, int, char*){return 0;} | |
void foo3(){} | |
int main(){ | |
std::cout << arg_count(foo) << std::endl; // 4 | |
std::cout << arg_count(foo2) << std::endl;// 3 | |
std::cout << arg_count(foo3) << std::endl;// 0 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment