![]() |
XII Release 0.1.0
|
Encapsulates a result state (success or failure), with [[nodiscard]] enforcement. More...
#include <Types.h>
Public Member Functions | |
Constructors and Assignments | |
| XII_ALWAYS_INLINE | xiiResult (xiiResultEnum result) |
| Constructs a result from an enum value. | |
| XII_ALWAYS_INLINE void | operator= (xiiResultEnum rhs) |
| Assigns a new result state. | |
| XII_ALWAYS_INLINE bool | operator== (xiiResultEnum cmp) const |
| Compares the result to another enum value. | |
Status Queries | |
| XII_ALWAYS_INLINE bool | Succeeded () const |
| Returns true if the result indicates success. | |
| XII_ALWAYS_INLINE bool | Failed () const |
| Returns true if the result indicates failure. | |
Control and Assertions | |
| XII_ALWAYS_INLINE void | IgnoreResult () |
| Suppresses compiler warnings when intentionally ignoring the result. | |
| void | AssertSuccess (const char *szMsg=nullptr, const char *szDetails=nullptr) const |
| Asserts that the result indicates success. | |
Encapsulates a result state (success or failure), with [[nodiscard]] enforcement.
Provides clearer semantics than using raw booleans and encourages consistent status checking in functions and APIs. Also includes convenience utilities for asserting or ignoring result values.
|
inline |
Constructs a result from an enum value.
Example:
| void xiiResult::AssertSuccess | ( | const char * | szMsg = nullptr, |
| const char * | szDetails = nullptr ) const |
Asserts that the result indicates success.
If the result is failure, the program terminates.
| szMsg | Optional short message for assertion failure. |
| szDetails | Optional detailed message, used in conjunction with szMsg. If szDetails is provided, szMsg should contain a formatting placeholder ({}). |
|
inline |
Suppresses compiler warnings when intentionally ignoring the result.
To be used when result checking isn't necessary, e.g., in best-effort cleanup code.