brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 87e10d1 Raw
75 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s2// expected-no-diagnostics3 4template<typename T>5concept C = sizeof(T) <= sizeof(long);6 7template<typename T>8struct A {9  template<typename U>10  void f(U) requires C<U>;11 12  void g() requires C<T>;13 14  template<typename U>15  void h(U) requires C<T>;16 17  constexpr int i() requires C<T> {18    return 0;19  }20 21  constexpr int i() requires C<T> && true {22    return 1;23  }24 25  template<>26  void f(char);27};28 29template<>30template<typename U>31void A<short>::f(U) requires C<U>;32 33template<>34template<typename U>35void A<short>::h(U) requires C<short>;36 37template<>38template<>39void A<int>::f(int);40 41template<>42void A<long>::g();43 44template<>45constexpr int A<long>::i() {46  return 2;47}48 49static_assert(A<long>().i() == 2);50 51template<typename T>52struct D {53  template<typename U>54  static constexpr int f(U);55 56  template<typename U>57  static constexpr int f(U) requires (sizeof(T) == 1);58 59  template<>60  constexpr int f(int) {61    return 1;62  }63};64 65template<>66template<typename U>67constexpr int D<signed char>::f(U) requires (sizeof(signed char) == 1) {68  return 0;69}70 71static_assert(D<char>::f(0) == 1);72static_assert(D<char[2]>::f(0) == 1);73static_assert(D<signed char>::f(0) == 1);74static_assert(D<signed char>::f(0.0) == 0);75