fork(1) download
  1. #include <iostream>
  2. #include <tuple>
  3. #include <utility>
  4.  
  5. template<std::size_t ... Is, typename Tuple>
  6. void print_helper(std::ostream& s, const Tuple& t, std::index_sequence<Is...>)
  7. {
  8. int dummy[] = { 0, ((s << std::get<Is>(t) << ", "), 0)...};
  9. (void) dummy; // remove warning for unused var
  10. }
  11.  
  12.  
  13. template<typename Tuple>
  14. void print(std::ostream& s, const Tuple& t)
  15. {
  16. print_helper(s, t, std::make_index_sequence<std::tuple_size<Tuple>::value>());
  17. }
  18.  
  19. int main()
  20. {
  21. print(std::cout, std::make_tuple("hello ", '*', 42));
  22. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
hello , *, 42,