File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -31,16 +31,19 @@ struct Error {
3131// ! `std::optional<T>` can be updated to return `util::Result<T>` and return
3232// ! error strings usually just replacing `return std::nullopt;` with `return
3333// ! util::Error{error_string};`.
34- template <class T >
34+ template <class M >
3535class Result
3636{
3737private:
38+ using T = std::conditional_t <std::is_same_v<M, void >, std::monostate, M>;
39+
3840 std::variant<bilingual_str, T> m_variant;
3941
4042 template <typename FT>
4143 friend bilingual_str ErrorString (const Result<FT>& result);
4244
4345public:
46+ Result () : m_variant{std::in_place_index_t <1 >{}, std::monostate{}} {} // constructor for void
4447 Result (T obj) : m_variant{std::in_place_index_t <1 >{}, std::move (obj)} {}
4548 Result (Error error) : m_variant{std::in_place_index_t <0 >{}, std::move (error.message )} {}
4649
You can’t perform that action at this time.
0 commit comments