diff --git a/src/util/result.h b/src/util/result.h index 972b1aada01..b99995c7e56 100644 --- a/src/util/result.h +++ b/src/util/result.h @@ -31,16 +31,19 @@ struct Error { //! `std::optional` can be updated to return `util::Result` and return //! error strings usually just replacing `return std::nullopt;` with `return //! util::Error{error_string};`. -template +template class Result { private: + using T = std::conditional_t, std::monostate, M>; + std::variant m_variant; template friend bilingual_str ErrorString(const Result& result); public: + Result() : m_variant{std::in_place_index_t<1>{}, std::monostate{}} {} // constructor for void Result(T obj) : m_variant{std::in_place_index_t<1>{}, std::move(obj)} {} Result(Error error) : m_variant{std::in_place_index_t<0>{}, std::move(error.message)} {}