|
WPILibC++
2020.3.2
|
Tagged union holding either a T or a Error. More...
#include <Error.h>
Public Types | |
| using | storage_type = typename std::conditional< isRef, wrap, T >::type |
| using | value_type = T |
Public Member Functions | |
| Expected (Error Err) | |
| Create an Expected<T> error value from the given Error. | |
| Expected (ErrorSuccess)=delete | |
| Forbid to convert from Error::success() implicitly, this avoids having Expected<T> foo() { return Error::success(); } which compiles otherwise but triggers the assertion above. | |
| template<typename OtherT > | |
| Expected (OtherT &&Val, typename std::enable_if< std::is_convertible< OtherT, T >::value >::type *=nullptr) | |
| Create an Expected<T> success value from the given OtherT value, which must be convertible to T. | |
| Expected (Expected &&Other) | |
| Move construct an Expected<T> value. | |
| template<class OtherT > | |
| Expected (Expected< OtherT > &&Other, typename std::enable_if< std::is_convertible< OtherT, T >::value >::type *=nullptr) | |
| Move construct an Expected<T> value from an Expected<OtherT>, where OtherT must be convertible to T. | |
| template<class OtherT > | |
| Expected (Expected< OtherT > &&Other, typename std::enable_if<!std::is_convertible< OtherT, T >::value >::type *=nullptr) | |
| Move construct an Expected<T> value from an Expected<OtherT>, where OtherT isn't convertible to T. | |
| Expected & | operator= (Expected &&Other) |
| Move-assign from another Expected<T>. | |
| ~Expected () | |
| Destroy an Expected<T>. | |
| operator bool () | |
| Return false if there is an error. | |
| reference | get () |
| Returns a reference to the stored T value. | |
| const_reference | get () const |
| Returns a const reference to the stored T value. | |
| template<typename ErrT > | |
| bool | errorIsA () const |
| Check that this Expected<T> is an error of type ErrT. | |
| Error | takeError () |
| Take ownership of the stored error. More... | |
| pointer | operator-> () |
| Returns a pointer to the stored T value. | |
| const_pointer | operator-> () const |
| Returns a const pointer to the stored T value. | |
| reference | operator* () |
| Returns a reference to the stored T value. | |
| const_reference | operator* () const |
| Returns a const reference to the stored T value. | |
Friends | |
| template<class T1 > | |
| class | ExpectedAsOutParameter |
| template<class OtherT > | |
| class | Expected |
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.
|
inline |
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> vaule.