11USERVER_NAMESPACE_BEGIN
19class ResultStore
final {
28 const T&
Get()
const&;
41 std::optional<T> value_;
42 std::exception_ptr exception_;
49class ResultStore<
void>
final {
64 bool has_value_{
false};
65 std::exception_ptr exception_;
71 return std::move(*value_);
74 std::rethrow_exception(exception_);
76 throw std::logic_error(
"result store is not ready");
80const T& ResultStore<T>::
Get()
const& {
85 std::rethrow_exception(exception_);
87 throw std::logic_error(
"result store is not ready");
97 value_.emplace(std::move(value));
101void ResultStore<T>::
SetException(std::exception_ptr&& exception)
noexcept {
102 exception_ = std::move(exception);
106inline void ResultStore<
void>::
Retrieve() { Get(); }
108inline void ResultStore<
void>::Get()
const& {
113 std::rethrow_exception(exception_);
115 throw std::logic_error(
"result store is not ready");
118inline void ResultStore<
void>::
SetValue()
noexcept { has_value_ =
true; }
120inline void ResultStore<
void>::
SetException(std::exception_ptr&& exception)
noexcept {
121 exception_ = std::move(exception);