| 1 |
// { dg-do run { target c++20 } } |
| 2 |
// { dg-do compile { target c++17_down } } |
| 3 |
// { dg-excess-errors "" { target { c++17_down } } } (PR108972) |
| 4 |
// { dg-additional-options "-flto" { target lto } } (PR107897) |
| 5 |
|
| 6 |
template<typename T> |
| 7 |
concept C1 = __is_same_as(T, int) |
| 8 |
|| __is_same_as(T, long long) |
| 9 |
|| __is_same_as(T, char); |
| 10 |
|
| 11 |
template<typename T> |
| 12 |
concept IsNotLarge = !__is_same_as(T, long long); |
| 13 |
|
| 14 |
template<typename T> |
| 15 |
concept IsNotTiny = !__is_same_as(T, char); |
| 16 |
|
| 17 |
template<IsNotLarge T> |
| 18 |
struct Foo |
| 19 |
{ |
| 20 |
static constexpr auto a = [](auto n) { return n; }; |
| 21 |
template<IsNotTiny S> |
| 22 |
auto b() |
| 23 |
{ |
| 24 |
return [](auto n) { return n; }; |
| 25 |
} |
| 26 |
}; |
| 27 |
|
| 28 |
using Func = int(*)(int); |
| 29 |
|
| 30 |
int main(int, char**) |
| 31 |
{ |
| 32 |
auto g = []<C1 T> requires IsNotTiny<T>(T t) -> T |
| 33 |
requires IsNotLarge<decltype(t)> { return t; }; |
| 34 |
g(5); |
| 35 |
g.operator()<int>(5.5); |
| 36 |
|
| 37 |
auto z = []<typename T, int N = 5>(T t) requires (N < 4) { return t; }; |
| 38 |
z.operator()<int, 3>(5); |
| 39 |
|
| 40 |
[](auto t) requires true { return t; }(5); |
| 41 |
[](C1 auto t) { return t; }(5); |
| 42 |
|
| 43 |
auto a0 = [](IsNotLarge auto a) { return [](auto b){ return b; }; }; |
| 44 |
auto a1 = a0(1); |
| 45 |
auto a2 = a1(5LL); |
| 46 |
|
| 47 |
auto b0 = [](auto a) { return [](IsNotLarge auto b){ return b; }; }; |
| 48 |
auto b1 = b0(5LL); |
| 49 |
auto b2 = b1(1); |
| 50 |
|
| 51 |
Foo<int> foo1; |
| 52 |
foo1.a(5.5); |
| 53 |
foo1.a(1LL); |
| 54 |
foo1.b<int>()(5); |
| 55 |
foo1.b<long long>()(5); |
| 56 |
|
| 57 |
Foo<double> foo2; |
| 58 |
foo2.a(5.5); |
| 59 |
foo2.a(1LL); |
| 60 |
foo2.b<int>()(5); |
| 61 |
foo2.b<long long>()(5); |
| 62 |
|
| 63 |
Func m1 = [](auto a) -> int requires true { return a; }; |
| 64 |
|
| 65 |
return 0; |
| 66 |
} |