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 {
31
31
// ! `std::optional<T>` can be updated to return `util::Result<T>` and return
32
32
// ! error strings usually just replacing `return std::nullopt;` with `return
33
33
// ! util::Error{error_string};`.
34
- template <class T >
34
+ template <class M >
35
35
class Result
36
36
{
37
37
private:
38
+ using T = std::conditional_t <std::is_same_v<M, void >, std::monostate, M>;
39
+
38
40
std::variant<bilingual_str, T> m_variant;
39
41
40
42
template <typename FT>
41
43
friend bilingual_str ErrorString (const Result<FT>& result);
42
44
43
45
public:
46
+ Result () : m_variant{std::in_place_index_t <1 >{}, std::monostate{}} {} // constructor for void
44
47
Result (T obj) : m_variant{std::in_place_index_t <1 >{}, std::move (obj)} {}
45
48
Result (Error error) : m_variant{std::in_place_index_t <0 >{}, std::move (error.message )} {}
46
49
You can’t perform that action at this time.
0 commit comments