fork download
  1. #include <cstdlib>
  2. #include <cstdio>
  3.  
  4. struct foo {
  5. const char *const _str;
  6.  
  7. template <size_t E>
  8. constexpr foo (const char (&str)[E]) : _str(str) {}
  9. template <size_t E>
  10. constexpr foo (char (&str)[E]) = delete;
  11.  
  12. void print() const {
  13. const char local_copy[6] = {
  14. _str[0], _str[1], _str[2], _str[3], _str[4], 0
  15. };
  16. puts(local_copy);
  17. }
  18. };
  19.  
  20. constexpr foo ohyeah = "moo";
  21.  
  22. void _foo (const foo &f) {
  23. f.print();
  24. }
  25.  
  26. #define MK_STATIC 0
  27.  
  28. foo getfoo() {
  29. #if MK_STATIC
  30. static
  31. #endif
  32. const char cbar[] = "cblah";
  33. return cbar;
  34. }
  35.  
  36. int main ()
  37. {
  38. _foo(getfoo());
  39. //foo ohnoez = cbar;
  40. //char bar[] = "blah";
  41. //foo ohyeah2 = bar;
  42. }
  43.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
��_��