fork download
  1. #include <iostream>
  2.  
  3.  
  4. void printSingle(double d)
  5. {
  6. std::cout << "DBL!!! " << d << " ";
  7. }
  8.  
  9. template <typename T>
  10. void printSingle(const T& t)
  11. {
  12. std::cout << t << " ";
  13. }
  14.  
  15. template <typename...ARGS>
  16. void Print(const ARGS&...args) {
  17. const int dummy[] = {0, (printSingle(args), 0)...};
  18. static_cast<void>(dummy); // Avoid warning for unused variable
  19. std::cout << std::endl;
  20. }
  21.  
  22. int main() {
  23. Print(1.1, 2, 3.3, 4);
  24. Print(0, 1.1, 2, 3.3, 4);
  25. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
DBL!!! 1.1 2 DBL!!! 3.3 4 
0 DBL!!! 1.1 2 DBL!!! 3.3 4