| 1 |
// PR c++/115550 - wrong deduction when passing *this to promise ctor template |
| 2 |
|
| 3 |
#include <coroutine> |
| 4 |
|
| 5 |
template <typename T> struct remove_reference { using type = T; }; |
| 6 |
template <typename T> struct remove_reference<T&> { using type = T; }; |
| 7 |
template <typename T> struct remove_reference<T&&> { using type = T; }; |
| 8 |
template <typename T> using remove_reference_t = remove_reference<T>::type; |
| 9 |
|
| 10 |
template <typename, typename> |
| 11 |
struct is_same { static inline constexpr bool value = false; }; |
| 12 |
template <typename T> |
| 13 |
struct is_same<T, T> { static inline constexpr bool value = true; }; |
| 14 |
|
| 15 |
template <typename T, typename U> |
| 16 |
concept same_as = is_same<T, U>::value; |
| 17 |
|
| 18 |
struct coroutine |
| 19 |
{ |
| 20 |
struct promise_type |
| 21 |
{ |
| 22 |
template <typename Arg> |
| 23 |
explicit promise_type(Arg&&) |
| 24 |
{ |
| 25 |
static_assert(same_as< |
| 26 |
remove_reference_t<remove_reference_t<Arg>>, |
| 27 |
remove_reference_t<Arg> |
| 28 |
>); |
| 29 |
} |
| 30 |
|
| 31 |
coroutine get_return_object() { return {}; } |
| 32 |
|
| 33 |
std::suspend_never initial_suspend() noexcept { return {}; } |
| 34 |
std::suspend_never final_suspend() noexcept { return {}; } |
| 35 |
|
| 36 |
void return_void() {} |
| 37 |
void unhandled_exception() {throw;} |
| 38 |
}; |
| 39 |
}; |
| 40 |
|
| 41 |
struct x |
| 42 |
{ |
| 43 |
coroutine f() |
| 44 |
{ |
| 45 |
co_return; |
| 46 |
} |
| 47 |
}; |