fork download
  1. #include <iostream>
  2.  
  3. template <typename T>
  4. void test(T&& arg)
  5. {
  6. arg += arg;
  7. }
  8.  
  9. int main() {
  10. int i = 12;
  11. std::string s("ab");
  12. std::cout << "i = " << i << " s = " << s << std::endl;
  13. test(i);
  14. std::cout << "i = " << i << std::endl;
  15. test((int)i);
  16. std::cout << "i = " << i << std::endl;
  17. test(s);
  18. std::cout << "s = " << s << std::endl;
  19. test((std::string)s);
  20. std::cout << "s = " << s << std::endl;
  21. return 0;
  22. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
i = 12   s = ab
i = 24
i = 24
s = abab
s = abab