Template result container with typed error information. More...
#include <tres.hpp>
Public Member Functions | |
| tres (const T &value) | |
| tres (const R &value) | |
| R & | getErr () |
| Gets the contained error. | |
| const R & | getErr () const BY_CONST_FUNC(getErr()) void rel() override |
| Releases/clears both the contained value and the error, making the instance empty. | |
| void | set (const T &arg) override |
| Sets the contained value and clears any existing error. | |
| void | setErr (const R &arg) |
| Sets the contained error and clears any existing value. | |
Public Member Functions inherited from by::tmay< T > | |
| tmay (const T &value) | |
| tmay (const tmedium< T > &value) | |
| T * | operator-> () |
| const T * | operator-> () const BY_CONST_FUNC(operator->()) |
| T & | operator* () |
| const T & | operator* () const BY_CONST_FUNC(operator*()) |
| operator T& () | |
| operator const T & () const | |
| operator nbool () const | |
| nbool | has () const |
| T * | get () |
| Gets the contained value. | |
| const T * | get () const BY_CONST_FUNC(get()) virtual void rel() |
| Releases/clears the contained value, making the instance empty. | |
Template result container with typed error information.
Identical to tmay but allows defining a custom error type when errors occur. While tmay<T> can only indicate whether an error occurred or not, tres<T, R> can provide detailed error information of type R when an error occurs.
Example comparing tmay and tres:
Common error types include std::string for error messages, or custom error enums for categorized error handling.
Gets the contained error.
Sets the contained value and clears any existing error.
Reimplemented from by::tmay< T >.