Debian Codegraph @

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

raw
1 // { dg-do compile { target c++20 } }
2
3 // A poor mans Integral concept.
4 template<typename T>
5 concept Integral = __is_same_as(T, int);
6
7 template<int N>
8 concept Nonnegative = N >= 0;
9
10 template<typename... Args>
11 concept UnaryPack = (sizeof...(Args) == 1);
12
13 template<typename... Args>
14 requires Integral<Args...> // { dg-error "non-pack parameter" }
15 void f1();
16
17 template<typename... Args>
18 requires Integral<Args>... // { dg-error "parameter packs not expanded|expected unqualified-id" }
19 void f2();
20
21 template<typename... Args>
22 requires (Integral<Args> && ...)
23 void f3() { }
24
25 template<Integral... Args>
26 void f4() { }
27
28 // FIXME: This syntax is likely to be made invalid.
29 template<Nonnegative... Args> // { dg-error "does not constrain a type" }
30 void f5() { }
31
32 template<UnaryPack Arg> // requires UnaryPack<Arg>
33 void f6() { }
34
35 template<UnaryPack... Args> // requires (... && UnaryPack<Args>)
36 void f7() { }
37
38 void driver()
39 {
40 f1<int, int>(); // { dg-error "" }
41 f3<int, int>();
42 f3<int, void>(); // { dg-error "" }
43 f4<int, int>();
44 f4<int, void>(); // { dg-error "" }
45 f7<int>();
46 f7<int, int>();
47 }