Provides the ability to return T or E from a function, ensuring that T is only created if an error is not present.
More...
|
constexpr | result (T const &t) noexcept(//PRQA S 2180//NOLINT is_nothrow_copy_constructible< T >::value) |
| Constructs a bsl::result that contains T, by copying "t". More...
|
|
constexpr | result (T &&t) noexcept(//PRQA S 2180//NOLINT is_nothrow_move_constructible< T >::value) |
| Constructs a bsl::result that contains T, by moving "t". More...
|
|
template<typename... ARGS> |
constexpr | result (bsl::in_place_t const &ip, ARGS &&... args) noexcept(is_nothrow_constructible< T, ARGS... >::value) |
| Constructs a bsl::result that contains T by constructing T in place. More...
|
|
constexpr | result (E const &e, sloc_type const &sloc=here()) noexcept |
| Constructs a bsl::result that contains E, by copying "e". More...
|
|
constexpr | result (E &&e, sloc_type const &sloc=here()) noexcept |
| Constructs a bsl::result that contains E, by moving "e". More...
|
|
BSL_CONSTEXPR | ~result () noexcept(is_nothrow_destructible< T >::value) |
| Destroyes a previously created bsl::result. Since we require E to be trivially destructible, we only need to call a destructor if this object contains a T. More...
|
|
constexpr | result (result const &o) noexcept(//PRQA S 4285 is_nothrow_copy_constructible< T >::value) |
| copy constructor More...
|
|
constexpr | result (result &&o) noexcept(//PRQA S 4285 is_nothrow_move_constructible< T >::value) |
| move constructor More...
|
|
constexpr result & | operator= (result const &o) &noexcept(is_nothrow_copy_constructible< T >::value &&is_nothrow_swappable< T >::value) |
| copy assignment More...
|
|
constexpr result & | operator= (result &&o) &noexcept(is_nothrow_move_constructible< T >::value &&is_nothrow_swappable< T >::value) |
| move assignment More...
|
|
template<typename O > |
constexpr | result (O val) noexcept=delete |
| This constructor allows for single argument constructors without the need to mark them as explicit as it will absorb any incoming potential implicit conversion and prevent it. More...
|
|
constexpr T * | get_if () &noexcept |
| Returns a handle to T if this object contains T, otherwise it returns a nullptr. More...
|
|
constexpr T * | get_if () &&noexcept=delete |
| Prevents the use of get_if() on temporary objects, which would result in UB. More...
|
|
constexpr T const * | get_if () const &noexcept |
| Returns a handle to T if this object contains T, otherwise it returns a nullptr. More...
|
|
constexpr T const * | get_if () const &&noexcept=delete |
| Prevents the use of get_if() on temporary objects, which would result in UB. More...
|
|
constexpr E | errc (E const &fallback=E{}) const noexcept |
| Returns an error code if this object contains E, otherwise it returns "fallback". More...
|
|
constexpr bool | success () const noexcept |
| Returns true if the bsl::result contains T, otherwise, if the bsl::result contains an error code, returns false. More...
|
|
constexpr bool | failure () const noexcept |
| Returns true if the bsl::result contains E, otherwise, if the bsl::result contains T, returns false. More...
|
|
|
(Note that these are not member functions.)
|
template<typename T , typename E > |
constexpr bool | operator== (result< T, E > const &lhs, result< T, E > const &rhs) noexcept |
| Returns true if the lhs is equal to the rhs, false otherwise. More...
|
|
template<typename T , typename E > |
constexpr bool | operator!= (result< T, E > const &lhs, result< T, E > const &rhs) noexcept |
| Returns false if the lhs is equal to the rhs, true otherwise. More...
|
|
template<typename T, typename E = errc_type>
class bsl::result< T, E >
Provides the ability to return T or E from a function, ensuring that T is only created if an error is not present.
namespace bsl
{
inline void
example_result_overview() noexcept
{
if (auto const *const ptr = res.get_if()) {
}
}
}
- Template Parameters
-
T | the nullable type |
E | the error type to use |