LLVM API Documentation
Represents either an error or a value T. More...
#include <ErrorOr.h>
Public Types | |
typedef conditional< isRef, wrap, T >::type | storage_type |
typedef void(* | unspecified_bool_type )() |
Public Member Functions | |
template<class E > | |
ErrorOr (E ErrorCode, typename enable_if_c< is_error_code_enum< E >::value||is_error_condition_enum< E >::value, void * >::type=0) | |
ErrorOr (llvm::error_code EC) | |
ErrorOr (T Val) | |
ErrorOr (const ErrorOr &Other) | |
template<class OtherT > | |
ErrorOr (const ErrorOr< OtherT > &Other) | |
ErrorOr & | operator= (const ErrorOr &Other) |
template<class OtherT > | |
ErrorOr & | operator= (const ErrorOr< OtherT > &Other) |
~ErrorOr () | |
operator unspecified_bool_type () const | |
Return false if there is an error. More... | |
operator llvm::error_code () const | |
pointer | operator-> () |
reference | operator* () |
Static Public Member Functions | |
static void | unspecified_bool_true () |
Friends | |
template<class OtherT > | |
class | ErrorOr |
Represents either an error or a value T.
ErrorOr<T> is a pointer-like class that represents the result of an operation. The result is either an error, or a value of type T. This is designed to emulate the usage of returning a pointer where nullptr indicates failure. However instead of just knowing that the operation failed, we also have an error_code and optional user data that describes why it failed.
It is used like the following.
An implicit conversion to bool provides a way to check if there was an error. The unary * and -> operators provide pointer like access to the value. Accessing the value when there is an error has undefined behavior.
When T is a reference type the behaivor is slightly different. The reference is held in a std::reference_wrapper<std::remove_reference<T>::type>, and there is special handling to make operator -> work as if T was not a reference.
T cannot be a rvalue reference.
typedef conditional< isRef , wrap , T >::type llvm::ErrorOr< T >::storage_type |
typedef void(* llvm::ErrorOr< T >::unspecified_bool_type)() |
|
inline |
Definition at line 112 of file ErrorOr.h.
References llvm::make_error_code().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 182 of file ErrorOr.h.
References llvm::error_code::success().
|
inline |
Return false if there is an error.
Definition at line 178 of file ErrorOr.h.
References llvm::ErrorOr< T >::unspecified_bool_true().
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
Definition at line 175 of file ErrorOr.h.
Referenced by llvm::ErrorOr< T >::operator unspecified_bool_type().
AlignedCharArrayUnion<error_code> llvm::ErrorOr< T >::ErrorStorage |
AlignedCharArrayUnion<storage_type> llvm::ErrorOr< T >::TStorage |