brintos

brintos / llvm-project-archived public Read only

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