MT Core (C++)
Core library for replacing C++ standard in project usage
|
Represents a Result that may have an error (error code) or a success value A type of "void" means there is no Result value, but there may be a failure. More...
#include <result.hpp>
Public Types | |
using | Err = ErrType |
using | ErrVal = Error<Err> |
using | Value = T |
Public Member Functions | |
Result (const T &val) | |
Creates a Result object from a success Allows for implicit casting by returning success value. | |
Result (T &&val) | |
Creates a Result object from a success Allows for implicit casting by returning success value. | |
bool | operator== (const Result &other) const noexcept |
Compares results. | |
bool | operator!= (const Result &other) const noexcept |
bool | operator== (const T &other) const noexcept |
Compares Result to a value. | |
bool | operator!= (const T &other) const noexcept |
bool | is_success () const noexcept |
Checks if is a successful Result (aka. | |
T | value () const noexcept |
Checks if is a successful Result (aka. | |
bool | is_error () const noexcept |
Checks if is an error Result. | |
bool | copy_if_present (std::remove_const_t< T > &out) const noexcept |
Copies into a reference the successful value if there is one. | |
bool | move_if_present (T &out) noexcept |
Moves into a reference the successful value if there is one. | |
ErrVal | error () const noexcept |
Returns the associated error Fails if there is no error;. | |
const T & | operator* () const noexcept |
Dereference the value (fails if an error value) | |
T const * | operator-> () const noexcept |
Dereference the value (fails if an error value) | |
T & | operator* () |
Dereference the value (fails if an error value) | |
T * | operator-> () |
Dereference the value (fails if an error value) | |
Result< void, Err > | to_void () const |
template<typename R> | |
Result< R, Err > | with_success_val (const R &s) |
Static Public Member Functions | |
static Result | from_error (const ErrVal &err) |
Creates a Result object from an error. | |
static Result | from_success (const T &val) |
Creates a Result object from a success. | |
Represents a Result that may have an error (error code) or a success value A type of "void" means there is no Result value, but there may be a failure.
Represents a Result that has a success value or an error.
Definition at line 170 of file result.hpp.
using mtcore::Result< T, ErrType >::Err = ErrType |
Definition at line 171 of file result.hpp.
using mtcore::Result< T, ErrType >::ErrVal = Error<Err> |
Definition at line 172 of file result.hpp.
using mtcore::Result< T, ErrType >::Value = T |
Definition at line 173 of file result.hpp.
|
inline |
Creates a Result object from a success Allows for implicit casting by returning success value.
val | Success code |
Definition at line 185 of file result.hpp.
|
inline |
Creates a Result object from a success Allows for implicit casting by returning success value.
val | Success code |
Definition at line 193 of file result.hpp.
|
inlinenodiscardnoexcept |
Copies into a reference the successful value if there is one.
Definition at line 271 of file result.hpp.
|
inlinenodiscardnoexcept |
Returns the associated error Fails if there is no error;.
Definition at line 294 of file result.hpp.
|
inlinestatic |
Creates a Result object from an error.
err | Error code |
Definition at line 200 of file result.hpp.
|
inlinestatic |
|
inlinenodiscardnoexcept |
Checks if is an error Result.
Definition at line 266 of file result.hpp.
|
inlinenodiscardnoexcept |
Checks if is a successful Result (aka.
has a value)
Definition at line 253 of file result.hpp.
|
inlinenodiscardnoexcept |
Moves into a reference the successful value if there is one.
Definition at line 281 of file result.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 248 of file result.hpp.
|
inline |
Dereference the value (fails if an error value)
Definition at line 318 of file result.hpp.
|
inlinenoexcept |
Dereference the value (fails if an error value)
Definition at line 302 of file result.hpp.
|
inline |
Dereference the value (fails if an error value)
Definition at line 326 of file result.hpp.
|
inlinenoexcept |
Dereference the value (fails if an error value)
Definition at line 310 of file result.hpp.
|
inlinenoexcept |
Compares results.
other | Other Result to compare against |
Definition at line 214 of file result.hpp.
|
inlinenoexcept |
|
inline |
|
inlinenodiscardnoexcept |
Checks if is a successful Result (aka.
has a value)
Definition at line 258 of file result.hpp.
|
inline |