fork(35) download
  1. #include <iostream>
  2.  
  3. template <typename R, typename ... Types> constexpr size_t getArgumentCount( R(*f)(Types ...))
  4. {
  5. return sizeof...(Types);
  6. }
  7.  
  8. void foo(int a, int b, int c)
  9. {
  10. }
  11.  
  12. int bar()
  13. {
  14. return 0;
  15. }
  16.  
  17. int baz(double)
  18. {
  19. return 0;
  20. }
  21.  
  22. int main()
  23. {
  24. std::cout << getArgumentCount(foo) << std::endl;
  25. std::cout << getArgumentCount(bar) << std::endl;
  26. std::cout << getArgumentCount(baz) << std::endl;
  27. return 0;
  28. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
3
0
1