Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/concepts/req1.C @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 // { dg-do compile } | |
2 // { dg-options "-std=c++17 -fconcepts" } | |
3 | |
4 template<typename T> | |
5 concept bool Class () { return __is_class(T); } | |
6 | |
7 // Allow a requires-expression with no parms. | |
8 template<typename T> | |
9 concept bool C = requires { typename T::type; }; | |
10 | |
11 void f1(auto a) requires Class<decltype(a)>() { } | |
12 void f2(auto a) requires requires (decltype(a) x) { -x; } { } | |
13 | |
14 struct S { } s; | |
15 | |
16 // Allow non-type template parms as constraints. | |
17 template<bool B> requires B struct S0; // OK | |
18 | |
19 template<int N> requires N struct S1 { }; // { dg-error "does not have type" } | |
20 template<int N> requires N == 0 struct S2 { }; // OK | |
21 | |
22 template<typename T, T X> requires X struct S3 { }; // OK | |
23 S3<int, 0> s3a; // { dg-error "constraint failure|does not have type" } | |
24 S3<bool, false> s3b; // { dg-error "constraint failure" } | |
25 | |
26 int main() { | |
27 f1(s); | |
28 f2(0); | |
29 } |