@@ -27,3 +27,62 @@ static_assert(foo<'a'>() == 3);
27
27
// expected-error@-1{{call to 'foo' is ambiguous}}
28
28
// expected-note@#cand2 {{candidate function}}
29
29
// expected-note@#cand3 {{candidate function}}
30
+
31
+
32
+ namespace case1 {
33
+
34
+ template <auto T, decltype (T) U>
35
+ concept C1 = sizeof (T) >= 4 ; // #case1_C1
36
+
37
+ template <typename Y, char V>
38
+ concept C2 = C1<Y{}, V>; // #case1_C2
39
+
40
+ template <class T , char W>
41
+ constexpr int foo () requires C2<T, W> { return 1 ; } // #case1_foo1
42
+
43
+ template <class T , char X>
44
+ constexpr int foo () requires C1<T{}, X> && true { return 2 ; } // #case1_foo2
45
+
46
+ static_assert (foo<char , ' a' >() == 2 );
47
+ // expected-error@-1{{no matching function for call to 'foo'}}
48
+ // expected-note@#case1_foo1{{candidate template ignored: constraints not satisfied [with T = char, W = 'a']}}
49
+ // expected-note@#case1_foo1{{because 'C2<char, 'a'>' evaluated to false}}
50
+ // expected-note@#case1_C2{{because 'C1<Y{}, V>' evaluated to false}}
51
+ // expected-note@#case1_C1{{because 'sizeof ('\x00') >= 4' (1 >= 4) evaluated to false}}
52
+ // expected-note@#case1_foo2{{candidate template ignored: constraints not satisfied [with T = char, X = 'a']}}
53
+ // expected-note@#case1_foo2{{because 'C1<char{}, 'a'>' evaluated to false}}
54
+ // expected-note@#case1_C1{{because 'sizeof ('\x00') >= 4' (1 >= 4) evaluated to false}}
55
+
56
+ static_assert (foo<int , ' a' >() == 2 );
57
+
58
+ }
59
+
60
+ namespace case2 {
61
+ template <auto T> concept C1 = sizeof (decltype (T)) >= 0 ;
62
+ template <typename Y> concept C2 = C1<Y{}>;
63
+
64
+ template <char W>
65
+ constexpr int foo () requires C2<int> { return 1 ; }
66
+
67
+ template <char X>
68
+ constexpr int foo () requires C1<0> && true { return 2 ; }
69
+
70
+ static_assert (foo<0 >() == 2 );
71
+ }
72
+
73
+ namespace case3 {
74
+ template <auto T> concept C1 = sizeof (decltype (T)) >= 0 ;
75
+
76
+ template <typename Y> concept C2 = C1<Y{}>;
77
+
78
+ template <char W>
79
+ constexpr int foo () requires C2<int> { return 1 ; } // #case3_foo1
80
+
81
+ template <char X>
82
+ constexpr int foo () requires C1<1> && true { return 2 ; } // #case3_foo2
83
+
84
+ static_assert (foo<0 >() == 2 );
85
+ // expected-error@-1{{call to 'foo' is ambiguous}}
86
+ // expected-note@#case3_foo1 {{candidate function}}
87
+ // expected-note@#case3_foo2 {{candidate function}}
88
+ }
0 commit comments