fork download
  1. #include <iostream>
  2.  
  3. static void printHelper()
  4. {
  5. }
  6.  
  7. template <typename T>
  8. static void printHelper(T&& arg)
  9. {
  10. std::cout << arg;
  11. }
  12.  
  13. template<typename T, typename ...Args>
  14. static void printHelper(T&& arg, Args&& ...args)
  15. {
  16. std::cout << arg << ", ";
  17. printHelper(args...);
  18. }
  19.  
  20. class Factory
  21. {
  22. public:
  23. template<typename ...Args>
  24. static void testFunc(Args&& ...args)
  25. {
  26. std::cout << "inside function; args are: ";
  27. printHelper(args...);
  28. std::cout << std::endl;
  29. }
  30. };
  31.  
  32. int main()
  33. {
  34. void (*pFunc1)() = &Factory::testFunc<>;
  35. pFunc1();
  36.  
  37. void (*pFunc2)(int&&, char&&, double&&) = &Factory::testFunc<int, char, double>;
  38. pFunc2(1, 'a', 3.14);
  39. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
inside function; args are: 
inside function; args are: 1, a, 3.14