File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed
Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 22/cmake-build- *
33.idea
44* .out
5- tt .py
5+ / * .py
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ ASYNCIO_NS_BEGIN
1313template <typename T>
1414struct Result {
1515 constexpr bool has_value () const noexcept {
16- return std::get_if<T >(&result_) ! = nullptr ;
16+ return std::get_if<std::monostate >(&result_) = = nullptr ;
1717 }
1818 template <typename R>
1919 constexpr void set_value (R&& value) noexcept {
@@ -53,19 +53,21 @@ struct Result {
5353
5454template <>
5555struct Result <void > {
56- bool has_value () const noexcept {
57- return result_ != nullptr ;
56+ constexpr bool has_value () const noexcept {
57+ return result_.has_value ();
58+ }
59+ constexpr void return_void () noexcept {
60+ result_.emplace (nullptr );
5861 }
59- constexpr void return_void () noexcept { }
6062 void result () {
61- if (result_) { std::rethrow_exception (result_); }
63+ if (result_. has_value () && *result_ != nullptr ) { std::rethrow_exception (* result_); }
6264 }
6365
6466 void set_exception (std::exception_ptr exception) noexcept { result_ = exception; }
6567 void unhandled_exception () noexcept { result_ = std::current_exception (); }
6668
6769private:
68- std::exception_ptr result_;
70+ std::optional<std:: exception_ptr> result_;
6971};
7072
7173ASYNCIO_NS_END
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ ASYNCIO_NS_BEGIN
1515namespace detail {
1616template <typename R, typename Duration>
1717struct WaitForAwaiter : NonCopyable {
18- constexpr bool await_ready () noexcept { return false ; }
18+ constexpr bool await_ready () noexcept { return result_. has_value () ; }
1919 constexpr decltype (auto ) await_resume() {
2020 return result_.result ();
2121 }
You can’t perform that action at this time.
0 commit comments