1 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
3 // expected-no-diagnostics
5 template <class T
, class U
> constexpr bool is_same_v
= false;
6 template <class T
> constexpr bool is_same_v
<T
, T
> = true;
7 template <class T
, class U
>
8 concept is_same
= is_same_v
<T
, U
>;
10 template <class T
> struct X
{};
11 template <class T
, class U
>
12 concept C1
= is_same
<T
, X
<U
>>;
14 template <class T1
> X
<X
<X
<T1
>>> t1() {
15 return []<class T2
>(T2
) -> X
<X
<T2
>> {
18 return []<class T3
>(T3
) -> X
<T3
> {
19 static_assert(is_same
<T2
, X
<T1
>>);
20 static_assert(is_same
<T3
, X
<T2
>>);
28 template X
<X
<X
<int>>> t1
<int>();
30 #if 0 // FIXME: crashes
31 template<class T1
> auto t2() {
32 return []<class T2
>(T2
) {
35 return []<class T3
>(T3
) {
36 static_assert(is_same
<T2
, X
<T1
>>);
37 static_assert(is_same
<T3
, X
<T2
>>);
45 template auto t2
<int>();
46 static_assert(is_same
<decltype(t2
<int>()), X
<X
<X
<int>>>>);
48 template<class T1
> C1
<X
<X
<T1
>>> auto t3() {
49 return []<C1
<T1
> T2
>(T2
) -> C1
<X
<T2
>> auto {
52 return []<C1
<T2
> T3
>(T3
) -> C1
<T3
> auto {
60 template C1
<X
<X
<int>>> auto t3
<int>();
61 static_assert(is_same
<decltype(t3
<int>()), X
<X
<X
<int>>>>);