fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <typename T>
  5. void func(const T &x)
  6. {
  7. cout << "const " << x << '\n';
  8. }
  9.  
  10. template <typename T>
  11. void func(T &x)
  12. {
  13. cout << "non-const " << x << '\n';
  14. }
  15.  
  16. int three() { return 3; }
  17.  
  18. int main()
  19. {
  20. int x = 1;
  21. const int y = 2;
  22. func(x);
  23. func(y);
  24. func(three());
  25. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
non-const 1
const 2
const 3