fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #include <iostream>
  5.  
  6. int count_args() {
  7. return 0;
  8. }
  9.  
  10. template<typename T, typename... Vs>
  11. int count_args(T _, Vs... vs) {
  12. return 1+count_args(vs...);
  13. }
  14.  
  15. template<int N,typename... Vs>
  16. bool is_arg_divisible(Vs... vs) {
  17. return count_args(vs...) % N == 0;
  18. }
  19.  
  20. int main() {
  21. std::cout << is_arg_divisible<3>() << std::endl;
  22. std::cout << is_arg_divisible<3>(1) << std::endl;
  23. std::cout << is_arg_divisible<3>(1, 2) << std::endl;
  24. std::cout << is_arg_divisible<3>(1, 2, 3) << std::endl;
  25. std::cout << is_arg_divisible<3>(1, 2, 3, 4) << std::endl;
  26. std::cout << is_arg_divisible<3>(1, 2, 3, 4, 5) << std::endl;
  27. std::cout << is_arg_divisible<3>(1, "", 3, '4', 5, 6) << std::endl;
  28. }
  29.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
1
0
0
1
0
0
1