Awaits on something that returns an std::optional and throws if it does not have a value.
More...
#include <TryAwait.hpp>
template<class T, bool is_rvalue_reference = true>
class fiber::_TryAwait< T, is_rvalue_reference >
Awaits on something that returns an std::optional and throws if it does not have a value.
Example:
int result =
co_await TryAwait(async_func());
}
Owning handle to a coroutine with a custom promise type.
Definition Coroutine.hpp:135
Future and Promise pairs are used to synchronise values between asynchronous tasks.
Definition Future.hpp:62
_TryAwait< T, true > TryAwait(fiber::Future< T > &&future)
Wraps an awaitable that returns an std::optional conditionally unpacks it or throws if there is no va...
Definition TryAwait.hpp:144
int main()
Definition test_main.cpp:23
◆ _TryAwait()
template<class T, bool is_rvalue_reference = true>
Hijacks the other awaitable or Future.
◆ await_ready()
template<class T, bool is_rvalue_reference = true>
Forwards the ready call to the real awaitable.
◆ await_resume()
template<class T, bool is_rvalue_reference = true>
Unpacks the std::optional from the true awaitables await_resume
Either returns the the unpacked value of the true awaitables await_resume or throws an fiber::Exception if that optional does not contain a value.
- Exceptions
-
| `fiber::Exception` | if the awaitables result of type std::otional does not have a value. |
- Returns
- the unpacked value fot the
std::optional from the real awaitables await_resume
◆ await_suspend()
template<class T, bool is_rvalue_reference = true>
template<class ReturnType>
Forwards the suspend call to the real awaitable.
The documentation for this class was generated from the following file: