Debian Codegraph @

clang/test/SemaTemplate/partial-order.cpp

raw
1 // RUN: %clang_cc1 -std=c++26 %s -verify
2
3 namespace hana_enable_if_idiom {
4 template<bool> struct A {};
5 template<typename, typename = A<true>> struct B;
6 template<typename T, bool N> struct B<T, A<N>> {};
7 template<typename T> struct B<T, A<T::value>> {};
8 struct C {
9 static const bool value = true;
10 };
11 B<C> b;
12 }
13
14 namespace GH132562 {
15 struct I {
16 int v = 0;
17 };
18
19 namespace t1 {
20 template <I... X> struct A;
21 template <I... X>
22 requires ((X.v == 0) ||...)
23 struct A<X...>;
24 } // namespace t1
25 namespace t2 {
26 template <I... X> struct A; // expected-note {{template is declared here}}
27 template <int... X> struct A<X...>;
28 // expected-error@-1 {{is not more specialized than the primary template}}
29 // expected-note@-2 {{no viable conversion from 'int' to 'I'}}
30
31 template <int... X> struct B; // expected-note {{template is declared here}}
32 template <I... X> struct B<X...>;
33 // expected-error@-1 {{is not more specialized than the primary template}}
34 // expected-note@-2 {{value of type 'const I' is not implicitly convertible to 'int'}}
35 } // namespace t2
36 namespace t3 {
37 struct J {
38 int v = 0;
39 constexpr J(int v) : v(v) {}
40 };
41 template <J... X> struct A;
42 template <int... X> struct A<X...>;
43
44 template <int... X> struct B; // expected-note {{template is declared here}}
45 template <J... X> struct B<X...>;
46 // expected-error@-1 {{is not more specialized than the primary template}}
47 // expected-note@-2 {{value of type 'const J' is not implicitly convertible to 'int'}}
48 } // namespace t3
49 } // namespace GH132562
50
51 namespace GH51866 {
52
53 template <class> struct Trait;
54 template <class T>
55 requires T::one
56 struct Trait<T> {}; // #gh51866-one
57 template <class T>
58 requires T::two
59 struct Trait<T> {}; // #gh51866-two
60
61 struct Y {
62 static constexpr bool one = true;
63 static constexpr bool two = true;
64 };
65
66 template <class T>
67 concept C = sizeof(Trait<T>) != 0;
68
69 static_assert(!C<Y>);
70
71 Trait<Y> t;
72 // expected-error@-1{{ambiguous partial specializations of 'Trait<GH51866::Y>'}}
73 // expected-note@#gh51866-one{{partial specialization matches}}
74 // expected-note@#gh51866-two{{partial specialization matches}}
75 }