fork(2) download
  1. #include <iostream>
  2. #include <sstream>
  3.  
  4. template<typename T, typename... Args>
  5. void toStream(T& stream, Args... args)
  6. {
  7. bool dummy[] = { (stream << args, true)... };
  8. }
  9.  
  10. int main()
  11. {
  12. std::stringstream s;
  13. toStream(s, 1, "abc", 2, "lol");
  14. std::cout << s.str();
  15.  
  16. std::cout << "\nlub\n";
  17.  
  18. toStream(std::cout, 1, "abc", 2, "lol");
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1abc2lol
lub
1abc2lol