fork download
  1. #include <iostream>
  2.  
  3. void foo(double me) {
  4. std::cout << "I am floating cockerel " << me << std::endl;
  5. }
  6.  
  7. void foo(int me) {
  8. std::cout << "Je suis integer " << me << std::endl;
  9. }
  10.  
  11. void foo(const char * me) {
  12. std::cout << "Soy string " << me << std::endl;
  13. }
  14.  
  15. template<int what> auto kukareku();
  16.  
  17. template<> auto kukareku<0>() {return 42;}
  18. template<> auto kukareku<1>() {return 3.14;}
  19. template<> auto kukareku<2>() {return "stroka";}
  20.  
  21. int main() {
  22. foo(kukareku<0>());
  23. foo(kukareku<1>());
  24. foo(kukareku<2>());
  25.  
  26. foo(42);
  27. foo(3.14);
  28. foo("stroka");
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 4516KB
stdin
Standard input is empty
stdout
Je suis integer 42
I am floating cockerel 3.14
Soy string stroka
Je suis integer 42
I am floating cockerel 3.14
Soy string stroka