Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions stl/inc/experimental/generator
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ namespace experimental {
struct generator {
struct promise_type {
_Ty const* _CurrentValue;
#if 1 // TRANSITION, VSO-1172852
#ifdef _CPPUNWIND
// TRANSITION, VSO-967814
exception_ptr _Eptr;
#endif // _CPPUNWIND
#endif // TRANSITION, VSO-1172852

auto get_return_object() {
return generator{*this};
Expand All @@ -55,19 +56,29 @@ namespace experimental {
return {};
}

#ifdef _CPPUNWIND
#if defined(_CPPUNWIND) || defined(__cpp_impl_coroutine)
void unhandled_exception() noexcept {
#if 1 // TRANSITION, VSO-1172852
#ifdef _CPPUNWIND
_Eptr = _STD current_exception();
}
#else // ^^^ _CPPUNWIND / !_CPPUNWIND vvv
abort();
#endif // _CPPUNWIND
#else // ^^^ workaround / no workaround vvv
throw;
#endif // TRANSITION, VSO-1172852
}
#endif // defined(_CPPUNWIND) || defined(__cpp_impl_coroutine)

#if 1 // TRANSITION, VSO-1172852
void _Rethrow_if_exception() {
#ifdef _CPPUNWIND
if (_Eptr) {
_STD rethrow_exception(_Eptr);
}
#endif // _CPPUNWIND
}
#endif // TRANSITION, VSO-1172852

auto yield_value(_Ty const& _Value) {
_CurrentValue = _STD addressof(_Value);
Expand Down Expand Up @@ -117,7 +128,11 @@ namespace experimental {
iterator& operator++() {
_Coro.resume();
if (_Coro.done()) {
#if 1 // TRANSITION, VSO-1172852
_STD exchange(_Coro, {}).promise()._Rethrow_if_exception();
#else // ^^^ workaround / no workaround vvv
_Coro = nullptr;
#endif // TRANSITION, VSO-1172852
}

return *this;
Expand Down Expand Up @@ -150,7 +165,9 @@ namespace experimental {
if (_Coro) {
_Coro.resume();
if (_Coro.done()) {
#if 1 // TRANSITION, VSO-1172852
_Coro.promise()._Rethrow_if_exception();
#endif // TRANSITION, VSO-1172852
return {nullptr};
}
}
Expand All @@ -164,10 +181,8 @@ namespace experimental {

explicit generator(promise_type& _Prom) : _Coro(coroutine_handle<promise_type>::from_promise(_Prom)) {}

generator() = default;

generator() = default;
generator(generator const&) = delete;

generator& operator=(generator const&) = delete;

generator(generator&& _Right) : _Coro(_Right._Coro) {
Expand Down