| 1 |
// PR c++/101165 - P2266R1 - Simpler implicit move |
| 2 |
// { dg-do compile { target c++23 } } |
| 3 |
// From [diff.cpp20.expr]. |
| 4 |
|
| 5 |
template<typename T, typename U> |
| 6 |
struct same_type { static const bool value = false; }; |
| 7 |
|
| 8 |
template<typename T> |
| 9 |
struct same_type<T, T> { static const bool value = true; }; |
| 10 |
|
| 11 |
// In C++23, returns int&&; previously returned int&. |
| 12 |
decltype(auto) f(int&& x) { return (x); } |
| 13 |
static_assert(same_type<decltype(f), int&& (int&&)>::value); |
| 14 |
|
| 15 |
// This used to work in C++20. |
| 16 |
int& g(int&& x) { return x; } // { dg-error "cannot bind non-const lvalue reference" } |
| 17 |
|
| 18 |
template<typename T> |
| 19 |
decltype(auto) h(T&& x) { return (x); } |
| 20 |
static_assert(same_type<decltype(h(42)), int&&>::value); |