Added move constructor for different type to result

This commit is contained in:
Patrick Urbanke
2023-10-11 21:49:50 +02:00
parent 94b8ab368b
commit 823f796519
+8
View File
@@ -45,6 +45,14 @@ class Result {
Result(Error&& _err) noexcept : t_or_err_(std::move(_err)) {}
template <class U, typename std::enable_if<std::is_convertible_v<U, T>,
bool>::type = true>
Result(Result<U>&& _other)
: t_or_err_(
std::forward<Result<U>>(_other)
.transform([](U&& _u) { return T(std::forward<U>(_u)); })
.t_or_err_) {}
template <class U, typename std::enable_if<std::is_convertible_v<U, T>,
bool>::type = true>
Result(const Result<U>& _other)