| 1 |
// { dg-do compile { target c++17 } } |
| 2 |
// { dg-options "-fconcepts" } |
| 3 |
|
| 4 |
template<typename T> |
| 5 |
concept C1 = __is_same_as(T, int); |
| 6 |
|
| 7 |
template<int N> |
| 8 |
concept C2 = N == 0; |
| 9 |
|
| 10 |
template<template<typename> class X> |
| 11 |
concept C3 = false; |
| 12 |
|
| 13 |
template<typename> struct Foo; |
| 14 |
|
| 15 |
// Instantiation of default arguments happens at the point of |
| 16 |
// instantiation for the class. |
| 17 |
|
| 18 |
template<C1 T = char> struct S1 { }; |
| 19 |
template<C2 N = 1> struct S2 { }; // { dg-error "does not constrain a type" } |
| 20 |
template<C3 X = Foo> struct S3 { }; // { dg-error "does not constrain a type|missing" } |
| 21 |
|
| 22 |
S1<> s1; // { dg-error "constraint failure|invalid type" } |
| 23 |
S2<> s2; // { dg-error "constraint failure|invalid" } |
| 24 |
S3<> s3; // { dg-error "constraint failure|invalid" } |