Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/concepts-fn3.C

raw
1 // { dg-do compile { target c++20 } }
2
3 template<typename T>
4 concept type = true;
5
6 template<typename T, typename U>
7 concept same_as = __is_same_as(T, U);
8
9 template<typename T>
10 concept integral = __is_same_as(T, int);
11
12 template<typename... Ts>
13 concept all_integral = (integral<Ts> && ...);
14
15 void f1(integral auto... args) { }
16 void f2(all_integral auto... args) { }
17
18 template<type T> requires true
19 void f3(T, integral auto... args) { }
20
21 template<type T>
22 struct S
23 {
24 void f1(integral auto... args) { }
25 void f2(all_integral auto... args) { }
26
27 template<type U> requires true
28 void f3(U, integral auto... args) { }
29 };
30
31 int main()
32 {
33 f1(1, 2, 3);
34 f1(1, 2, 3u); // { dg-error "" }
35 f2(1, 2, 3);
36 f2(1, 2, 3u); // { dg-error "" }
37 f3(1, 2, 3);
38 f3(1, 2, 3u); // { dg-error "" }
39 f3(1u, 2, 3);
40
41 S<void> s;
42 s.f1(1, 2, 3);
43 s.f1(1, 2, 3u); // { dg-error "no matching function" }
44 s.f2(1, 2, 3);
45 s.f2(1, 2, 3u); // { dg-error "no matching function" }
46 s.f3(1, 2, 3);
47 s.f3(1, 2, 3u); // { dg-error "no matching function" }
48 s.f3(1u, 2, 3);
49 }