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

Member Variables

private anonymous struct / union
private bool HasError
private static const bool isRef = std::is_reference<type-parameter-0-0>::value

Method Overview

  • public ErrorOr<T>(const ErrorOr<T> & Other)
  • public template <class E> ErrorOr<T>(E ErrorCode, std::enable_if_t<std::is_error_code_enum<E>::value || std::is_error_condition_enum<E>::value, void *> = nullptr)
  • public template <class OtherT> ErrorOr<T>(OtherT && Val, std::enable_if_t<std::is_convertible<OtherT, T>::value> * = nullptr)
  • public ErrorOr<T>(std::error_code EC)
  • public template <class OtherT> ErrorOr<T>(const ErrorOr<OtherT> & Other, std::enable_if_t<std::is_convertible<OtherT, T>::value> * = nullptr)
  • public template <class OtherT> ErrorOr<T>(const ErrorOr<OtherT> & Other, std::enable_if_t<!std::is_convertible<OtherT, const T &>::value> * = nullptr)
  • public template <class OtherT> ErrorOr<T>(ErrorOr<OtherT> && Other, std::enable_if_t<std::is_convertible<OtherT, T>::value> * = nullptr)
  • public template <class OtherT> ErrorOr<T>(ErrorOr<OtherT> && Other, std::enable_if_t<!std::is_convertible<OtherT, T>::value> * = nullptr)
  • public ErrorOr<T>(ErrorOr<T> && Other)
  • private template <class T1>static bool compareThisIfSameType(const T1 & a, const T1 & b)
  • private template <class T1, class T2>static bool compareThisIfSameType(const T1 & a, const T2 & b)
  • private template <class OtherT>void copyAssign(const ErrorOr<OtherT> & Other)
  • private template <class OtherT>void copyConstruct(const ErrorOr<OtherT> & Other)
  • public llvm::ErrorOr::const_reference get() const
  • public llvm::ErrorOr::reference get()
  • public std::error_code getError() const
  • private std::error_code * getErrorStorage()
  • private const std::error_code * getErrorStorage() const
  • private const llvm::ErrorOr::storage_type * getStorage() const
  • private llvm::ErrorOr::storage_type * getStorage()
  • private template <class OtherT>void moveAssign(ErrorOr<OtherT> && Other)
  • private template <class OtherT>void moveConstruct(ErrorOr<OtherT> && Other)
  • public bool operator bool() const
  • private llvm::ErrorOr::const_pointer toPointer(const llvm::ErrorOr::wrap * Val) const
  • private llvm::ErrorOr::pointer toPointer(llvm::ErrorOr::wrap * Val)
  • private llvm::ErrorOr::const_pointer toPointer(llvm::ErrorOr::const_pointer Val) const
  • private llvm::ErrorOr::pointer toPointer(llvm::ErrorOr::pointer Val)
  • public ~ErrorOr<T>()

Methods

ErrorOr<T>(const ErrorOr<T>& Other)

Declared at: llvm/include/llvm/Support/ErrorOr.h:93

Parameters

const ErrorOr<T>& Other

template <class E>
ErrorOr<T>(
    E ErrorCode,
    std::enable_if_t<
        std::is_error_code_enum<E>::value ||
            std::is_error_condition_enum<
                E>::value,
        void*> = nullptr)

Declared at: llvm/include/llvm/Support/ErrorOr.h:74

Templates

E

Parameters

E ErrorCode
std::enable_if_t< std::is_error_code_enum<E>::value || std::is_error_condition_enum<E>::value, void*> = nullptr

template <class OtherT>
ErrorOr<T>(
    OtherT&& Val,
    std::enable_if_t<
        std::is_convertible<OtherT, T>::value>* =
        nullptr)

Declared at: llvm/include/llvm/Support/ErrorOr.h:87

Templates

OtherT

Parameters

OtherT&& Val
std::enable_if_t< std::is_convertible<OtherT, T>::value>* = nullptr

ErrorOr<T>(std::error_code EC)

Declared at: llvm/include/llvm/Support/ErrorOr.h:82

Parameters

std::error_code EC

template <class OtherT>
ErrorOr<T>(
    const ErrorOr<OtherT>& Other,
    std::enable_if_t<
        std::is_convertible<OtherT, T>::value>* =
        nullptr)

Declared at: llvm/include/llvm/Support/ErrorOr.h:98

Templates

OtherT

Parameters

const ErrorOr<OtherT>& Other
std::enable_if_t< std::is_convertible<OtherT, T>::value>* = nullptr

template <class OtherT>
ErrorOr<T>(const ErrorOr<OtherT>& Other,
           std::enable_if_t<!std::is_convertible<
               OtherT,
               const T&>::value>* = nullptr)

Declared at: llvm/include/llvm/Support/ErrorOr.h:104

Templates

OtherT

Parameters

const ErrorOr<OtherT>& Other
std::enable_if_t< !std::is_convertible<OtherT, const T&>::value>* = nullptr

template <class OtherT>
ErrorOr<T>(
    ErrorOr<OtherT>&& Other,
    std::enable_if_t<
        std::is_convertible<OtherT, T>::value>* =
        nullptr)

Declared at: llvm/include/llvm/Support/ErrorOr.h:116

Templates

OtherT

Parameters

ErrorOr<OtherT>&& Other
std::enable_if_t< std::is_convertible<OtherT, T>::value>* = nullptr

template <class OtherT>
ErrorOr<T>(
    ErrorOr<OtherT>&& Other,
    std::enable_if_t<
        !std::is_convertible<OtherT, T>::value>* =
        nullptr)

Declared at: llvm/include/llvm/Support/ErrorOr.h:124

Templates

OtherT

Parameters

ErrorOr<OtherT>&& Other
std::enable_if_t< !std::is_convertible<OtherT, T>::value>* = nullptr

ErrorOr<T>(ErrorOr<T>&& Other)

Declared at: llvm/include/llvm/Support/ErrorOr.h:111

Parameters

ErrorOr<T>&& Other

template <class T1>
static bool compareThisIfSameType(const T1& a,
                                  const T1& b)

Declared at: llvm/include/llvm/Support/ErrorOr.h:184

Templates

T1

Parameters

const T1& a
const T1& b

template <class T1, class T2>
static bool compareThisIfSameType(const T1& a,
                                  const T2& b)

Declared at: llvm/include/llvm/Support/ErrorOr.h:189

Templates

T1
T2

Parameters

const T1& a
const T2& b

template <class OtherT>
void copyAssign(const ErrorOr<OtherT>& Other)

Declared at: llvm/include/llvm/Support/ErrorOr.h:194

Templates

OtherT

Parameters

const ErrorOr<OtherT>& Other

template <class OtherT>
void copyConstruct(const ErrorOr<OtherT>& Other)

Declared at: llvm/include/llvm/Support/ErrorOr.h:171

Templates

OtherT

Parameters

const ErrorOr<OtherT>& Other

llvm::ErrorOr::const_reference get() const

Declared at: llvm/include/llvm/Support/ErrorOr.h:151

llvm::ErrorOr::reference get()

Declared at: llvm/include/llvm/Support/ErrorOr.h:150

std::error_code getError() const

Declared at: llvm/include/llvm/Support/ErrorOr.h:153

std::error_code* getErrorStorage()

Declared at: llvm/include/llvm/Support/ErrorOr.h:246

const std::error_code* getErrorStorage() const

Declared at: llvm/include/llvm/Support/ErrorOr.h:251

const llvm::ErrorOr::storage_type* getStorage()
    const

Declared at: llvm/include/llvm/Support/ErrorOr.h:241

llvm::ErrorOr::storage_type* getStorage()

Declared at: llvm/include/llvm/Support/ErrorOr.h:236

template <class OtherT>
void moveAssign(ErrorOr<OtherT>&& Other)

Declared at: llvm/include/llvm/Support/ErrorOr.h:216

Templates

OtherT

Parameters

ErrorOr<OtherT>&& Other

template <class OtherT>
void moveConstruct(ErrorOr<OtherT>&& Other)

Declared at: llvm/include/llvm/Support/ErrorOr.h:203

Templates

OtherT

Parameters

ErrorOr<OtherT>&& Other

bool operator bool() const

Description

Return false if there is an error.

Declared at: llvm/include/llvm/Support/ErrorOr.h:146

llvm::ErrorOr::const_pointer toPointer(
    const llvm::ErrorOr::wrap* Val) const

Declared at: llvm/include/llvm/Support/ErrorOr.h:234

Parameters

const llvm::ErrorOr::wrap* Val

llvm::ErrorOr::pointer toPointer(
    llvm::ErrorOr::wrap* Val)

Declared at: llvm/include/llvm/Support/ErrorOr.h:230

Parameters

llvm::ErrorOr::wrap* Val

llvm::ErrorOr::const_pointer toPointer(
    llvm::ErrorOr::const_pointer Val) const

Declared at: llvm/include/llvm/Support/ErrorOr.h:228

Parameters

llvm::ErrorOr::const_pointer Val

llvm::ErrorOr::pointer toPointer(
    llvm::ErrorOr::pointer Val)

Declared at: llvm/include/llvm/Support/ErrorOr.h:224

Parameters

llvm::ErrorOr::pointer Val

~ErrorOr<T>()

Declared at: llvm/include/llvm/Support/ErrorOr.h:140