32template <
typename... Args>
34 if (std::holds_alternative<std::exception_ptr>(result))
35 std::rethrow_exception(std::get<std::exception_ptr>(std::move(result)));
42 std::variant<std::monostate, std::exception_ptr, T>
result;
45 template <std::convertible_to<T> U>
47 std::is_nothrow_constructible_v<T, decltype(std::forward<U>(value))>) {
48 result.template emplace<T>(std::forward<U>(value));
51 [[nodiscard]]
const T &
get() const & {
53 return std::get<T>(this->result);
56 [[nodiscard]] T &&
get() && {
58 return std::get<T>(std::move(this->result));
67 std::variant<std::monostate, std::exception_ptr, T *>
result;
70 void set_value(T &value)
noexcept { result = std::addressof(value); }
72 [[nodiscard]] T &
get()
const {
74 return *std::get<T *>(this->result);
82 std::variant<std::monostate, std::exception_ptr>
result;
void set_value(T &value) noexcept
std::variant< std::monostate, std::exception_ptr, T * > result
std::variant< std::monostate, std::exception_ptr > result
Storage class that can either contain a value, an exception, or be empty.
std::variant< std::monostate, std::exception_ptr, T > result
void set_value(U &&value) noexcept(std::is_nothrow_constructible_v< T, decltype(std::forward< U >(value))>)
Storage class that can either contain a value, an exception, or be empty.
void set_exception(std::exception_ptr ptr) noexcept
void check_and_rethrow(const std::variant< Args... > &result)
If rethrow contains an exception, rethrow it.