fork download
  1. #include <iostream>
  2.  
  3. template <int V>
  4. void div(char(*)[V - 1] = 0)
  5. {
  6. std::cout << "-1" << std::endl;
  7. }
  8. template <int V>
  9. void div(char(*)[V - 2] = 0)
  10. {
  11. std::cout << "-2" << std::endl;
  12. }
  13. template <int V>
  14. void div(char(*)[V - 3] = 0)
  15. {
  16. std::cout << "-3" << std::endl;
  17. }
  18.  
  19. int main()
  20. {
  21. div<3>();
  22. }
Compilation error #stdin compilation error #stdout 0s 3456KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:21:12: error: call of overloaded 'div()' is ambiguous
     div<3>();
            ^
prog.cpp:4:6: note: candidate: void div(char (*)[(V - 1)]) [with int V = 3]
 void div(char(*)[V - 1] = 0)
      ^
prog.cpp:9:6: note: candidate: void div(char (*)[(V - 2)]) [with int V = 3]
 void div(char(*)[V - 2] = 0)
      ^
stdout
Standard output is empty