Skip to content

Commit 94226cc

Browse files
committed
Fix Result::or_else not returning the return value of the callable
1 parent 2c8464a commit 94226cc

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

include/common/result.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ class Result<T, Errs...> {
170170
if constexpr (std::same_as<std::monostate, std::remove_cvref_t<decltype(arg)>>) {
171171
throw std::logic_error("This exception is unreachable");
172172
} else {
173-
std::invoke(f, std::forward<decltype(arg)>(arg));
174-
return std::forward<decltype(arg)>(arg);
173+
return std::invoke(f, std::forward<decltype(arg)>(arg));
175174
}
176175
}, std::forward<Self>(self).error);
177176
}
@@ -342,8 +341,7 @@ class Result<void, Errs...> {
342341
if constexpr (std::same_as<std::monostate, std::remove_cvref_t<decltype(arg)>>) {
343342
throw std::logic_error("This exception is unreachable");
344343
} else {
345-
std::invoke(f, std::forward<decltype(arg)>(arg));
346-
return std::forward<decltype(arg)>(arg);
344+
return std::invoke(f, std::forward<decltype(arg)>(arg));
347345
}
348346
}, std::forward<Self>(self).error);
349347
}

0 commit comments

Comments
 (0)