1 // RUN: %clang_cc1 -std=c++2a -x c++ %s -Wno-unused-value -verify
3 template <typename
... Args
> requires ((sizeof(Args
) == 1), ...)
4 // expected-note@-1 {{because '(sizeof(int) == 1) , (sizeof(char) == 1) , (sizeof(int) == 1)' evaluated to false}}
5 void f1(Args
&&... args
) { }
6 // expected-note@-1 {{candidate template ignored: constraints not satisfied [with Args = <int, char, int>]}}
8 using f11
= decltype(f1('a'));
9 using f12
= decltype(f1(1, 'b'));
10 using f13
= decltype(f1(1, 'b', 2));
11 // expected-error@-1 {{no matching function for call to 'f1'}}
13 template <typename
... Args
>
14 void f2(Args
&&... args
) requires ((sizeof(args
) == 1), ...) { }
15 // expected-note@-1 {{candidate template ignored: constraints not satisfied [with Args = <int, char, int>]}}
16 // expected-note@-2 {{because '(sizeof (args) == 1) , (sizeof (args) == 1) , (sizeof (args) == 1)' evaluated to false}}
18 using f21
= decltype(f2('a'));
19 using f22
= decltype(f2(1, 'b'));
20 using f23
= decltype(f2(1, 'b', 2));
21 // expected-error@-1 {{no matching function for call to 'f2'}}
23 template <typename
... Args
> requires ((sizeof(Args
) == 1), ...)
24 // expected-note@-1 {{because '(sizeof(int) == 1) , (sizeof(char) == 1) , (sizeof(int) == 1)' evaluated to false}}
25 void f3(Args
&&... args
) requires ((sizeof(args
) == 1), ...) { }
26 // expected-note@-1 {{candidate template ignored: constraints not satisfied [with Args = <int, char, int>]}}
28 using f31
= decltype(f3('a'));
29 using f32
= decltype(f3(1, 'b'));
30 using f33
= decltype(f3(1, 'b', 2));
31 // expected-error@-1 {{no matching function for call to 'f3'}}
36 static constexpr auto f(U
const index
) requires(index
, true) {
41 static_assert(S
<void>::f(1));
43 // Similar to the 'S' test, but tries to use 'U' in the requires clause.
44 template <typename T2
>
46 // expected-note@+3 {{candidate template ignored: constraints not satisfied [with U = int]}}
47 // expected-note@+3 {{because substituted constraint expression is ill-formed: type 'int' cannot be used prior to '::' because it has no members}}
49 static constexpr auto f(U
const index
)
54 // expected-error@+1 {{no matching function for call to 'f'}}
55 static_assert(S1
<void>::f(1));
57 constexpr auto value
= 0;
61 template<typename
= void> requires(value
, true)
62 static constexpr auto f() requires(value
, true) {
66 static_assert((S2
<int>::f(), true));
70 template<typename
... Args
> requires
true
71 static constexpr void f(Args
...) { }
74 static_assert((S3
<int>::f(), true));
79 constexpr void foo() requires (decltype(this)(), true) { }
80 constexpr void goo() requires (decltype(this)(), true) { }
83 static_assert((S4
<int>{}.foo
<int>(), S4
<int>{}.goo(), true));