fork download
  1. #include <iostream>
  2.  
  3. template < typename T > void write( T&& arg )
  4. {
  5. std::cout << "#args " << 1 << " => " ;
  6. std::cout << "write: " << arg << '\n' ;
  7. }
  8.  
  9. template < typename FIRST, typename... REST > void write( FIRST&& first, REST&&... rest )
  10. {
  11. std::cout << "#args " << 1 + sizeof...(rest) << " => " ;
  12. write(first) ;
  13. write(rest...) ;
  14. }
  15.  
  16. int main()
  17. {
  18. int i = 3 ;
  19. double d = 7.89 ;
  20. write( i, &i, d, -120000000000012LL, "hello world" ) ;
  21. }
  22.  
Success #stdin #stdout 0s 3344KB
stdin
Standard input is empty
stdout
#args 5  =>  #args 1 => write: 3
#args 4  =>  #args 1 => write: 0xbfe0c3a8
#args 3  =>  #args 1 => write: 7.89
#args 2  =>  #args 1 => write: -120000000000012
#args 1 => write: hello world