mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-07 03:06:18 +08:00
Added move constructor for different type to result
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user