class ErrorOr
Declaration
template <class T>
class ErrorOr { /* full declaration omitted */ };
Description
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. Implicit conversion to bool returns true if there is a usable value. 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 behavior 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.
Declared at: llvm/include/llvm/Support/ErrorOr.h:56
Templates
- T
Method Overview
- public ErrorOr<T>(std::error_code EC)
- public ErrorOr<T>(const ErrorOr<T> & Other)
- public ErrorOr<T>(ErrorOr<T> && Other)
- public template <class E> ErrorOr<T>(E ErrorCode, typename std::enable_if<std::is_error_code_enum<E>::value || std::is_error_condition_enum<E>::value, void *>::type = nullptr)
- public template <class OtherT> ErrorOr<T>(OtherT && Val, typename std::enable_if<std::is_convertible<OtherT, T>::value>::type * = nullptr)
- public template <class OtherT> ErrorOr<T>(const ErrorOr<OtherT> & Other, typename std::enable_if<std::is_convertible<OtherT, T>::value>::type * = nullptr)
- public template <class OtherT> ErrorOr<T>(const ErrorOr<OtherT> & Other, typename std::enable_if<!std::is_convertible<OtherT, const T &>::value>::type * = nullptr)
- public template <class OtherT> ErrorOr<T>(ErrorOr<OtherT> && Other, typename std::enable_if<std::is_convertible<OtherT, T>::value>::type * = nullptr)
- public template <class OtherT> ErrorOr<T>(ErrorOr<OtherT> && Other, typename std::enable_if<!std::is_convertible<OtherT, T>::value>::type * = nullptr)
- public llvm::ErrorOr::reference get()
- public llvm::ErrorOr::const_reference get() const
- public std::error_code getError() const
- public bool operator bool() const
- public ~ErrorOr<T>()
Methods
¶ErrorOr<T>(std::error_code EC)
ErrorOr<T>(std::error_code EC)
Declared at: llvm/include/llvm/Support/ErrorOr.h:82
Parameters
¶ErrorOr<T>(const ErrorOr<T>& Other)
ErrorOr<T>(const ErrorOr<T>& Other)
Declared at: llvm/include/llvm/Support/ErrorOr.h:94
Parameters
- const ErrorOr<T>& Other
¶ErrorOr<T>(ErrorOr<T>&& Other)
ErrorOr<T>(ErrorOr<T>&& Other)
Declared at: llvm/include/llvm/Support/ErrorOr.h:114
Parameters
- ErrorOr<T>&& Other
¶template <class E>
ErrorOr<T>(
E ErrorCode,
typename std::enable_if<
std::is_error_code_enum<E>::value ||
std::is_error_condition_enum<
E>::value,
void*>::type = nullptr)
template <class E>
ErrorOr<T>(
E ErrorCode,
typename std::enable_if<
std::is_error_code_enum<E>::value ||
std::is_error_condition_enum<
E>::value,
void*>::type = nullptr)
Declared at: llvm/include/llvm/Support/ErrorOr.h:74
Templates
- E
Parameters
- E ErrorCode
- typename std::enable_if< std::is_error_code_enum<E>::value || std::is_error_condition_enum<E>::value, void*>::type = nullptr
¶template <class OtherT>
ErrorOr<T>(
OtherT&& Val,
typename std::enable_if<
std::is_convertible<OtherT, T>::value>::
type* = nullptr)
template <class OtherT>
ErrorOr<T>(
OtherT&& Val,
typename std::enable_if<
std::is_convertible<OtherT, T>::value>::
type* = nullptr)
Declared at: llvm/include/llvm/Support/ErrorOr.h:87
Templates
- OtherT
Parameters
- OtherT&& Val
- typename std::enable_if< std::is_convertible<OtherT, T>::value>::type* = nullptr
¶template <class OtherT>
ErrorOr<T>(
const ErrorOr<OtherT>& Other,
typename std::enable_if<
std::is_convertible<OtherT, T>::value>::
type* = nullptr)
template <class OtherT>
ErrorOr<T>(
const ErrorOr<OtherT>& Other,
typename std::enable_if<
std::is_convertible<OtherT, T>::value>::
type* = nullptr)
Declared at: llvm/include/llvm/Support/ErrorOr.h:99
Templates
- OtherT
Parameters
- const ErrorOr<OtherT>& Other
- typename std::enable_if< std::is_convertible<OtherT, T>::value>::type* = nullptr
¶template <class OtherT>
ErrorOr<T>(
const ErrorOr<OtherT>& Other,
typename std::enable_if<!std::is_convertible<
OtherT,
const T&>::value>::type* = nullptr)
template <class OtherT>
ErrorOr<T>(
const ErrorOr<OtherT>& Other,
typename std::enable_if<!std::is_convertible<
OtherT,
const T&>::value>::type* = nullptr)
Declared at: llvm/include/llvm/Support/ErrorOr.h:107
Templates
- OtherT
Parameters
- const ErrorOr<OtherT>& Other
- typename std::enable_if< !std::is_convertible<OtherT, const T&>::value>::type* = nullptr
¶template <class OtherT>
ErrorOr<T>(
ErrorOr<OtherT>&& Other,
typename std::enable_if<
std::is_convertible<OtherT, T>::value>::
type* = nullptr)
template <class OtherT>
ErrorOr<T>(
ErrorOr<OtherT>&& Other,
typename std::enable_if<
std::is_convertible<OtherT, T>::value>::
type* = nullptr)
Declared at: llvm/include/llvm/Support/ErrorOr.h:119
Templates
- OtherT
Parameters
- ErrorOr<OtherT>&& Other
- typename std::enable_if< std::is_convertible<OtherT, T>::value>::type* = nullptr
¶template <class OtherT>
ErrorOr<T>(
ErrorOr<OtherT>&& Other,
typename std::enable_if<
!std::is_convertible<OtherT, T>::value>::
type* = nullptr)
template <class OtherT>
ErrorOr<T>(
ErrorOr<OtherT>&& Other,
typename std::enable_if<
!std::is_convertible<OtherT, T>::value>::
type* = nullptr)
Declared at: llvm/include/llvm/Support/ErrorOr.h:129
Templates
- OtherT
Parameters
- ErrorOr<OtherT>&& Other
- typename std::enable_if< !std::is_convertible<OtherT, T>::value>::type* = nullptr
¶llvm::ErrorOr::reference get()
llvm::ErrorOr::reference get()
Declared at: llvm/include/llvm/Support/ErrorOr.h:156
¶llvm::ErrorOr::const_reference get() const
llvm::ErrorOr::const_reference get() const
Declared at: llvm/include/llvm/Support/ErrorOr.h:157
¶std::error_code getError() const
std::error_code getError() const
Declared at: llvm/include/llvm/Support/ErrorOr.h:159
¶bool operator bool() const
bool operator bool() const
Description
Return false if there is an error.
Declared at: llvm/include/llvm/Support/ErrorOr.h:152
¶~ErrorOr<T>()
~ErrorOr<T>()
Declared at: llvm/include/llvm/Support/ErrorOr.h:146