9 #ifndef MLIR_SUPPORT_LOGICALRESULT_H
10 #define MLIR_SUPPORT_LOGICALRESULT_H
44 bool failed()
const {
return !isSuccess; }
78 class [[nodiscard]]
FailureOr :
public std::optional<T> {
84 "success should be constructed with an instance of 'T'");
87 FailureOr(T &&y) : std::optional<T>(std::forward<T>(y)) {}
90 std::enable_if_t<std::is_constructible<T, U>::value> * =
nullptr>
92 : std::optional<T>(
failed(other) ? std::optional<T>()
93 : std::optional<T>(*other)) {}
99 using std::optional<T>::operator bool;
100 using std::optional<T>::has_value;
104 template <
typename T,
105 typename = std::enable_if_t<!std::is_convertible_v<T, bool>>>
126 explicit operator bool()
const {
return failed(); }
This class provides support for representing a failure result, or a valid value of type T.
FailureOr(const FailureOr< U > &other)
FailureOr(LogicalResult result)
Allow constructing from a LogicalResult.
This class represents success/failure for parsing-like operations that find it important to chain tog...
ParseResult(LogicalResult result=success())
This header declares functions that assit transformations in the MemRef dialect.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
bool succeeded(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
This class represents an efficient way to signal success or failure.
bool succeeded() const
Returns true if the provided LogicalResult corresponds to a success value.
static LogicalResult success(bool isSuccess=true)
If isSuccess is true a success result is generated, otherwise a 'failure' result is generated.
static LogicalResult failure(bool isFailure=true)
If isFailure is true a failure result is generated, otherwise a 'success' result is generated.
bool failed() const
Returns true if the provided LogicalResult corresponds to a failure value.