From 0e1152c3fe478932f5768370c7c780cf678c3b63 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Tue, 30 Jan 2024 18:53:39 +0800 Subject: [PATCH 1/2] ``: Mark strengthened noexcept --- stl/inc/generator | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/stl/inc/generator b/stl/inc/generator index 22ff90589b7..0945f64c4f8 100644 --- a/stl/inc/generator +++ b/stl/inc/generator @@ -210,7 +210,7 @@ public: } _NODISCARD auto yield_value(const remove_reference_t<_Yielded>& _Val) noexcept( - is_nothrow_constructible_v, const remove_reference_t<_Yielded>&>) + is_nothrow_constructible_v, const remove_reference_t<_Yielded>&>) /* strengthened */ requires (is_rvalue_reference_v<_Yielded> && constructible_from, const remove_reference_t<_Yielded>&>) { @@ -225,7 +225,7 @@ public: template <_RANGES input_range _Rng, class _Alloc> requires convertible_to<_RANGES range_reference_t<_Rng>, _Yielded> - _NODISCARD auto yield_value(_RANGES elements_of<_Rng, _Alloc> _Elem) noexcept { + _NODISCARD auto yield_value(_RANGES elements_of<_Rng, _Alloc> _Elem) { using _Vty = _RANGES range_value_t<_Rng>; return _Nested_awaitable<_Yielded, _Vty, _Alloc>{ [](allocator_arg_t, _Alloc, _RANGES iterator_t<_Rng> _It, @@ -238,7 +238,7 @@ public: void await_transform() = delete; - void return_void() noexcept {} + void return_void() const noexcept {} void unhandled_exception() { if (_Info) { @@ -362,7 +362,7 @@ public: return *this; } - _NODISCARD _Ref operator*() const noexcept { + _NODISCARD _Ref operator*() const noexcept(is_nothrow_copy_constructible_v<_Ref>) { _STL_ASSERT(!_Coro.done(), "Can't dereference generator end iterator"); return static_cast<_Ref>(*_Coro.promise()._Top.promise()._Ptr); } @@ -377,8 +377,9 @@ public: ++*this; } - _NODISCARD bool operator==(default_sentinel_t) const noexcept { - return _Coro.done(); + _NODISCARD_FRIEND bool operator==(const _Gen_iter& _It, default_sentinel_t) noexcept /* strengthened */ + { + return _It._Coro.done(); } private: From c8c7929985b188895c98d53aff93e65102472559 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Wed, 31 Jan 2024 10:52:21 +0800 Subject: [PATCH 2/2] Fix conditional noexcept --- stl/inc/generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/generator b/stl/inc/generator index 0945f64c4f8..4cc08ae93fc 100644 --- a/stl/inc/generator +++ b/stl/inc/generator @@ -362,7 +362,7 @@ public: return *this; } - _NODISCARD _Ref operator*() const noexcept(is_nothrow_copy_constructible_v<_Ref>) { + _NODISCARD _Ref operator*() const noexcept(noexcept(static_cast<_Ref>(*_Coro.promise()._Top.promise()._Ptr))) { _STL_ASSERT(!_Coro.done(), "Can't dereference generator end iterator"); return static_cast<_Ref>(*_Coro.promise()._Top.promise()._Ptr); }