1 // RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
2 // expected-no-diagnostics
4 template <typename
, typename
>
5 constexpr bool is_same
= false;
7 constexpr bool is_same
<T
, T
> = true;
14 void check_category() {
17 auto [v
, r
] = S
{1, a
};
19 static_assert(is_same
<decltype(v
), int>);
20 static_assert(is_same
<decltype(r
), int &>);
24 auto [v
, r
] = S
{1, a
};
26 static_assert(is_same
<decltype(v
), int>);
27 static_assert(is_same
<decltype(r
), int &>);
32 const auto &[v
, r
] = s
;
34 static_assert(is_same
<decltype(v
), const int>);
35 static_assert(is_same
<decltype(r
), int &>);
40 const auto &[v
, r
] = s
;
42 static_assert(is_same
<decltype(v
), const int>);
43 static_assert(is_same
<decltype(r
), int &>);
49 int arr
[2] = {42, 42};
52 static_assert(is_same
<decltype(a
), int>);
53 static_assert(is_same
<decltype(b
), int>);
58 template <unsigned long I
>
59 decltype(auto) get() {
60 if constexpr (I
== 0) {
67 template <unsigned long I
>
68 decltype(auto) get() const {
69 if constexpr (I
== 0) {
84 static constexpr unsigned long value
= 2;
87 template <unsigned long, typename T
>
91 struct tuple_element
<0, tuple
> {
96 struct tuple_element
<1, tuple
> {
101 struct tuple_element
<0, const tuple
> {
106 struct tuple_element
<1, const tuple
> {
107 using type
= const int &;
111 void check_tuple_like() {
116 static_assert(is_same
<decltype(v
), int>);
117 static_assert(is_same
<decltype(r
), int &>);
123 static_assert(is_same
<decltype(v
), int>);
124 static_assert(is_same
<decltype(r
), int &>);
128 const auto &[v
, r
] = t
;
130 static_assert(is_same
<decltype(v
), int>);
131 static_assert(is_same
<decltype(r
), const int &>);
135 const auto &[v
, r
] = t
;
137 static_assert(is_same
<decltype(v
), int>);
138 static_assert(is_same
<decltype(r
), const int &>);