class Expected
Declaration
template <class T>
class Expected { /* full declaration omitted */ };
Description
Tagged union holding either a T or a Error. This class parallels ErrorOr, but replaces error_code with Error. Since Error cannot be copied, this class replaces getError() with takeError(). It also adds an bool errorIsA <ErrT >() method for testing the error class type.
Declared at: llvm/include/llvm/Support/Error.h:433
Templates
- T
Method Overview
- public Expected<T>(llvm::Error Err)
- public Expected<T>(llvm::ErrorSuccess)
- public Expected<T>(Expected<T> && Other)
- public template <typename OtherT> Expected<T>(OtherT && Val, typename std::enable_if<std::is_convertible<OtherT, T>::value>::type * = nullptr)
- public template <class OtherT> Expected<T>(Expected<OtherT> && Other, typename std::enable_if<std::is_convertible<OtherT, T>::value>::type * = nullptr)
- public template <class OtherT> Expected<T>(Expected<OtherT> && Other, typename std::enable_if<!std::is_convertible<OtherT, T>::value>::type * = nullptr)
- public template <typename ErrT>bool errorIsA() const
- public llvm::Expected::reference get()
- public llvm::Expected::const_reference get() const
- public bool operator bool()
- public llvm::Error takeError()
- public ~Expected<T>()
Methods
¶Expected<T>(llvm::Error Err)
Expected<T>(llvm::Error Err)
Description
Create an Expected <T > error value from the given Error.
Declared at: llvm/include/llvm/Support/Error.h:455
Parameters
- llvm::Error Err
¶Expected<T>(llvm::ErrorSuccess)
Expected<T>(llvm::ErrorSuccess)
Description
Forbid to convert from Error::success() implicitly, this avoids having Expected <T > foo() { return Error::success(); } which compiles otherwise but triggers the assertion above.
Declared at: llvm/include/llvm/Support/Error.h:469
Parameters
¶Expected<T>(Expected<T>&& Other)
Expected<T>(Expected<T>&& Other)
Description
Move construct an Expected <T > value.
Declared at: llvm/include/llvm/Support/Error.h:487
Parameters
- Expected<T>&& Other
¶template <typename OtherT>
Expected<T>(
OtherT&& Val,
typename std::enable_if<
std::is_convertible<OtherT, T>::value>::
type* = nullptr)
template <typename OtherT>
Expected<T>(
OtherT&& Val,
typename std::enable_if<
std::is_convertible<OtherT, T>::value>::
type* = nullptr)
Description
Create an Expected <T > success value from the given OtherT value, which must be convertible to T.
Declared at: llvm/include/llvm/Support/Error.h:474
Templates
- OtherT
Parameters
- OtherT&& Val
- typename std::enable_if< std::is_convertible<OtherT, T>::value>::type* = nullptr
¶template <class OtherT>
Expected<T>(
Expected<OtherT>&& Other,
typename std::enable_if<
std::is_convertible<OtherT, T>::value>::
type* = nullptr)
template <class OtherT>
Expected<T>(
Expected<OtherT>&& Other,
typename std::enable_if<
std::is_convertible<OtherT, T>::value>::
type* = nullptr)
Description
Move construct an Expected <T > value from an Expected <OtherT >, where OtherT must be convertible to T.
Declared at: llvm/include/llvm/Support/Error.h:492
Templates
- OtherT
Parameters
- Expected<OtherT>&& Other
- typename std::enable_if< std::is_convertible<OtherT, T>::value>::type* = nullptr
¶template <class OtherT>
Expected<T>(
Expected<OtherT>&& Other,
typename std::enable_if<
!std::is_convertible<OtherT, T>::value>::
type* = nullptr)
template <class OtherT>
Expected<T>(
Expected<OtherT>&& Other,
typename std::enable_if<
!std::is_convertible<OtherT, T>::value>::
type* = nullptr)
Description
Move construct an Expected <T > value from an Expected <OtherT >, where OtherT isn't convertible to T.
Declared at: llvm/include/llvm/Support/Error.h:501
Templates
- OtherT
Parameters
- Expected<OtherT>&& Other
- typename std::enable_if< !std::is_convertible<OtherT, T>::value>::type* = nullptr
¶template <typename ErrT>
bool errorIsA() const
template <typename ErrT>
bool errorIsA() const
Description
Check that this Expected <T > is an error of type ErrT.
Declared at: llvm/include/llvm/Support/Error.h:544
Templates
- ErrT
¶llvm::Expected::reference get()
llvm::Expected::reference get()
Description
Returns a reference to the stored T value.
Declared at: llvm/include/llvm/Support/Error.h:532
¶llvm::Expected::const_reference get() const
llvm::Expected::const_reference get() const
Description
Returns a const reference to the stored T value.
Declared at: llvm/include/llvm/Support/Error.h:538
¶bool operator bool()
bool operator bool()
Description
Return false if there is an error.
Declared at: llvm/include/llvm/Support/Error.h:524
¶llvm::Error takeError()
llvm::Error takeError()
Description
Take ownership of the stored error. After calling this the Expected <T > is in an indeterminate state that can only be safely destructed. No further calls (beside the destructor) should be made on the Expected <T > value.
Declared at: llvm/include/llvm/Support/Error.h:552
¶~Expected<T>()
~Expected<T>()
Description
Destroy an Expected <T >.
Declared at: llvm/include/llvm/Support/Error.h:515