Home | History | Annotate | Download | only in lex.ext
      1 // RUN: %clang_cc1 -std=c++11 -verify %s
      2 
      3 using size_t = decltype(sizeof(int));
      4 constexpr const char *operator "" _id(const char *p, size_t) { return p; }
      5 constexpr const char *s = "foo"_id "bar" "baz"_id "quux";
      6 
      7 constexpr bool streq(const char *p, const char *q) {
      8   return *p == *q && (!*p || streq(p+1, q+1));
      9 }
     10 static_assert(streq(s, "foobarbazquux"), "");
     11 
     12 constexpr const char *operator "" _trim(const char *p, size_t n) {
     13   return *p == ' ' ? operator "" _trim(p + 1, n - 1) : p;
     14 }
     15 constexpr const char *t = "   " " "_trim "  foo";
     16 static_assert(streq(t, "foo"), "");
     17 
     18 const char *u = "foo" "bar"_id "baz" "quux"_di "corge"; // expected-error {{differing user-defined suffixes ('_id' and '_di') in string literal concatenation}}
     19