Optional value wrapper for error indication without exceptions. More...
#include <tmay.hpp>
Public Member Functions | |
| 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. | |
| virtual void | set (const T &arg) |
Optional value wrapper for error indication without exceptions.
Provides a way to indicate errors in return-by-value functions without using slow exceptions. Functionally almost identical to std::optional<T>, but with API naming adapted to byeol project conventions.
For normal operation, pass the value as T& to the constructor. For error situations, pass a tmedium class created as nullptr.
has(), get(), rel(), and set() follow naming conventions used throughout the entire project.Example of using tmay for error handling:
Gets the contained value.
Reimplemented in by::tres< T, R >.