[mlir] Add a FailureOr copy constructor from a FailureOr of a convertible type.

This commit is contained in:
River Riddle 2021-07-27 20:27:37 +00:00
parent ddd8482117
commit e90a0d6381
1 changed files with 4 additions and 0 deletions

View File

@ -85,6 +85,10 @@ public:
FailureOr() : FailureOr(failure()) {}
FailureOr(T &&y) : Optional<T>(std::forward<T>(y)) {}
FailureOr(const T &y) : Optional<T>(y) {}
template <typename U,
std::enable_if_t<std::is_constructible<T, U>::value> * = nullptr>
FailureOr(const FailureOr<U> &other)
: Optional<T>(failed(other) ? Optional<T>() : Optional<T>(*other)) {}
operator LogicalResult() const { return success(this->hasValue()); }