Result of an operation: either a value or an error code (similar to C++23 std::expected).
More...
|
| constexpr | result (const error_type err) noexcept |
| | Conversion constructor for error.
|
| |
| constexpr | result (const value_type &val) |
| | Conversion constructor for value.
|
| |
| constexpr | result (value_type &&val) noexcept(std::is_nothrow_move_constructible_v< value_type >) |
| | Conversion constructor for r-value value.
|
| |
| constexpr bool_t | has_value () const noexcept |
| | Returns true if result has value.
|
| |
| constexpr | operator bool () const noexcept |
| | Returns true if result has value.
|
| |
| constexpr error_type | get_error () const noexcept |
| | Returns error code (error::NONE when result has value).
|
| |
| constexpr const value_type & | get_value () const & |
| | Returns value (throws std::bad_variant_access when result holds an error).
|
| |
| constexpr value_type & | get_value () & |
| | Returns value (throws std::bad_variant_access when result holds an error).
|
| |
| constexpr value_type && | get_value () && |
| | Returns value (throws std::bad_variant_access when result holds an error).
|
| |
| template<class U > |
| constexpr value_type | value_or (U &&default_value) const & |
| | Returns value or given default value when result holds an error.
|
| |
| constexpr const variant_type & | to_variant () const noexcept |
| | Conversion to variant.
|
| |
| template<class Visitor > |
| constexpr decltype(auto) | visit (Visitor &&visitor) const |
| | Visits value or error.
|
| |
| constexpr const value_type & | operator* () const &noexcept |
| | Returns value (unchecked, like std::optional).
|
| |
| constexpr value_type & | operator* () &noexcept |
| | Returns value (unchecked, like std::optional).
|
| |
| constexpr value_type && | operator* () &&noexcept |
| | Returns value (unchecked, like std::optional).
|
| |
| constexpr const value_type * | operator-> () const noexcept |
| | Returns pointer to value (unchecked, like std::optional).
|
| |
| constexpr value_type * | operator-> () noexcept |
| | Returns pointer to value (unchecked, like std::optional).
|
| |
| constexpr bool_t | operator== (const result &rhs) const |
| | Equality operator.
|
| |
| constexpr bool_t | operator== (const error_type err) const noexcept |
| | Equality operator (true when result holds given error).
|
| |
template<class T>
struct tpbrt::result< T >
Result of an operation: either a value or an error code (similar to C++23 std::expected).
A result never holds error::NONE: it is either a value or a real error.
- Template Parameters
-
| T | Type of value returned on success. |