fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T> void foo(T v);
  5.  
  6. template<> void foo<int>(int v)
  7. {
  8. std::cout << "non const version:" << v << std::endl;
  9. }
  10. template<> void foo<const int>(int v)
  11. {
  12. std::cout << "const version:" << v << std::endl;
  13. }
  14.  
  15. int main() {
  16. foo<int>(1);
  17. foo<const int>(1);
  18. return 0;
  19. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
non const version:1
const version:1