fork download
  1. #include <iostream>
  2.  
  3. template <size_t N>
  4. void foo_it(char const (&literal)[N]) {
  5. std::cout << literal << "\n";
  6. }
  7.  
  8. int main() {
  9. char not_a_literal[] = "Hello, World!";
  10. char const (&ref)[14] = not_a_literal;
  11.  
  12. foo_it(ref);
  13.  
  14. not_a_literal[7] = 'w';
  15.  
  16. foo_it(ref);
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Hello, World!
Hello, world!