fork download
  1. #include <iostream>
  2.  
  3. struct C {
  4. template<typename T>
  5. void fn(T) = delete;
  6.  
  7. template<size_t N>
  8. void fn(char const (&x)[N]){
  9. std::cout << x << N;
  10. }
  11. template<>
  12. void fn<char const *>(char const *x){
  13. std::cout << x;
  14. }
  15. } c;
  16.  
  17. int main() {
  18. c.fn("test");
  19. char const a[] = "test";
  20. c.fn(a);
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:11:11: error: explicit specialization in non-namespace scope ‘struct C’
  template<>
           ^
prog.cpp:12:37: error: template-id ‘fn<const char*>’ in declaration of primary template
  void fn<char const *>(char const *x){
                                     ^
stdout
Standard output is empty