1 //  { dg-additional-options "-fno-exceptions" }
2 
3 #include <coroutine>
4 #include <string>
5 
6 template <typename T>
7 struct looper {
8   struct promise_type {
get_return_objectlooper::promise_type9     auto get_return_object () { return handle_type::from_promise (*this); }
initial_suspendlooper::promise_type10     auto initial_suspend () { return suspend_always_prt {}; }
final_suspendlooper::promise_type11     auto final_suspend () noexcept { return suspend_always_prt {}; }
12     void return_value (T);
13     void unhandled_exception ();
14   };
15 
16   using handle_type = std::coroutine_handle<promise_type>;
17 
18   looper (handle_type);
19 
20   struct suspend_always_prt {
21     bool await_ready () noexcept;
22     void await_suspend (handle_type) noexcept;
23     void await_resume () noexcept;
24   };
25 };
26 
27 template <typename T>
28 looper<T>
with_ctorable_state(T)29 with_ctorable_state (T)
30 {
31   co_return T ();
32 }
33 
34 auto
foo()35 foo ()
36 {
37   return with_ctorable_state<std::string>;
38 }
39