fork(4) download
  1. #include <iostream>
  2. #include <initializer_list>
  3. #include <vector>
  4. #include <string>
  5. #include <iterator>
  6. #include <utility>
  7.  
  8. template<typename T>
  9. void printme_impl(T&& t) {
  10. for(auto it = t.begin(); it != t.end(); ++it)
  11. std::cout << *it;
  12. }
  13.  
  14. template<typename T>
  15. void printme(T&& t) {
  16. printme_impl(std::forward<T>(t));
  17. }
  18.  
  19. template<typename T>
  20. void printme(std::initializer_list<T> t) {
  21. printme_impl<std::initializer_list<T>&>(t);
  22. }
  23.  
  24. int main() {
  25. printme(std::vector<char>({'a', 'b', 'c'}));
  26. printme(std::string("abc"));
  27. printme({'a', 'b', 'c'});
  28. return 0;
  29. }
Success #stdin #stdout 0s 3060KB
stdin
Standard input is empty
stdout
abcabcabc