fork download
  1. #include <iostream>
  2.  
  3. void append_to_stream(std::ostream &stream)
  4. { }
  5.  
  6. template <typename T, typename... Args>
  7. void append_to_stream(std::ostream &stream, T &&first, Args&&... rest)
  8. {
  9. stream << std::forward< T >( first );
  10. append_to_stream(stream, std::forward< Args >( rest ) ...);
  11. }
  12.  
  13. typedef std::ostream & (&manip_t)( std::ostream & );
  14.  
  15. int main() {
  16.  
  17. append_to_stream(std::cout,
  18. "hello world",
  19. static_cast< manip_t >( std::endl ),
  20. static_cast< manip_t >( std::endl ) );
  21. std::cout << "done\n";
  22. }
  23.  
Success #stdin #stdout 0s 2828KB
stdin
Standard input is empty
stdout
hello world

done