fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. void f(...) {
  6. cout << "That one wasn't a string literal." << endl;
  7. }
  8.  
  9. template<size_t N>
  10. void f(const char (&s)[N]) {
  11. cout << "String literal: \"" << s << '"' << endl;
  12. }
  13.  
  14.  
  15. int main() {
  16. f("foo");
  17.  
  18. const char *bar = "bar";
  19. f(bar);
  20.  
  21. const char baz[] = "baz";
  22. f(baz);
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
String literal: "foo"
That one wasn't a string literal.
String literal: "baz"