brintos

brintos / llvm-project-archived public Read only

0
0
Text · 518 B · ff5d3de Raw
19 lines · cpp
1// RUN: %clang_cc1 -std=c++11 %s -verify2// expected-no-diagnostics3 4using size_t = decltype(sizeof(0));5template<typename T> struct check;6template<size_t N> struct check<const char[N]> {};7 8constexpr bool startswith(const char *p, const char *q) {9  return !*q || (*p == *q && startswith(p + 1, q + 1));10}11constexpr bool contains(const char *p, const char *q) {12  return *p && (startswith(p, q) || contains(p + 1, q));13}14 15void foo() {16  check<decltype(__func__)>();17  static_assert(contains(__func__, "foo"), "");18}19