Debian Codegraph @

clang/test/CXX/temp/temp.spec/temp.expl.spec/p8.cpp

raw
1 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
2 // expected-no-diagnostics
3
4 template<typename T>
5 concept C = sizeof(T) <= sizeof(long);
6
7 template<typename T>
8 struct 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
29 template<>
30 template<typename U>
31 void A<short>::f(U) requires C<U>;
32
33 template<>
34 template<typename U>
35 void A<short>::h(U) requires C<short>;
36
37 template<>
38 template<>
39 void A<int>::f(int);
40
41 template<>
42 void A<long>::g();
43
44 template<>
45 constexpr int A<long>::i() {
46 return 2;
47 }
48
49 static_assert(A<long>().i() == 2);
50
51 template<typename T>
52 struct 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
65 template<>
66 template<typename U>
67 constexpr int D<signed char>::f(U) requires (sizeof(signed char) == 1) {
68 return 0;
69 }
70
71 static_assert(D<char>::f(0) == 1);
72 static_assert(D<char[2]>::f(0) == 1);
73 static_assert(D<signed char>::f(0) == 1);
74 static_assert(D<signed char>::f(0.0) == 0);