C++ Utilities
Loading...
Searching...
No Matches
confirm.h

Assertion macros that are replacements for the standard confirm macro, and which improve on it in various ways.
See the Confirmations page for all the details. More...

Go to the source code of this file.

Macros

#define always_confirm(cond, ...)
 An confirmation macro that checks a boolean condition cond.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the condition that failed.
#define always_confirm_eq(lhs, rhs, ...)
 An confirmation macro that checks the equality of two values lhs and rhs.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the values that failed the equality check.
#define debug_confirm(cond, ...)
 An confirmation macro that checks a boolean condition cond.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the condition that failed.
#define debug_confirm_eq(a, b, ...)
 An confirmation macro that checks the equality of two values lhs and rhs.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the values that failed the equality check.
#define confirm(cond, ...)
 An confirmation macro that checks a boolean condition cond.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the condition that failed.
#define confirm_eq(lhs, rhs, ...)
 An confirmation macro that checks the equality of two values lhs and rhs.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the values that failed the equality check.

Detailed Description

Assertion macros that are replacements for the standard confirm macro, and which improve on it in various ways.
See the Confirmations page for all the details.

Macro Definition Documentation

◆ always_confirm

#define always_confirm ( cond,
... )
Value:
if (!(cond)) [[unlikely]] { failed(#cond, std::source_location::current() __VA_OPT__(, __VA_ARGS__)); }

An confirmation macro that checks a boolean condition cond.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the condition that failed.

The first argument is the condition to check, the (optional) rest are passed to std::format to form a custom extra message that is printed if the condition fails.

◆ always_confirm_eq

#define always_confirm_eq ( lhs,
rhs,
... )
Value:
if (!((lhs) == (rhs))) [[unlikely]] { \
failed_eq(#lhs, #rhs, (lhs), (rhs), std::source_location::current() __VA_OPT__(, __VA_ARGS__)); \
}

An confirmation macro that checks the equality of two values lhs and rhs.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the values that failed the equality check.

The first two arguments are the values to check for equality, the (optional) rest are passed to std::format to form a custom extra message that is printed if the values are not equal.

◆ confirm

#define confirm ( cond,
... )
Value:
always_confirm(cond __VA_OPT__(, __VA_ARGS__))
#define always_confirm(cond,...)
An confirmation macro that checks a boolean condition cond. On failure, the confirmation prints an ...
Definition confirm.h:42

An confirmation macro that checks a boolean condition cond.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the condition that failed.

NOTE: The confirm macro expands to a no-op only when the NDEBUG flag is set.

The first argument is the condition to check, the (optional) rest are passed to std::format to form a custom extra message that is printed if the condition fails.

◆ confirm_eq

#define confirm_eq ( lhs,
rhs,
... )
Value:
always_confirm_eq(lhs, rhs __VA_OPT__(, __VA_ARGS__))
#define always_confirm_eq(lhs, rhs,...)
An confirmation macro that checks the equality of two values lhs and rhs. On failure,...
Definition confirm.h:52

An confirmation macro that checks the equality of two values lhs and rhs.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the values that failed the equality check.

NOTE: The confirm_eq macro expands to a no-op only when the NDEBUG flag is set.

The first two arguments are the values to check for equality, the (optional) rest are passed to std::format to form a custom extra message that is printed if the values are not equal.

◆ debug_confirm

#define debug_confirm ( cond,
... )
Value:
void(0)

An confirmation macro that checks a boolean condition cond.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the condition that failed.

NOTE: The debug_confirm macro expands to a no-op unless the DEBUG flag is set.

The first argument is the condition to check, the (optional) rest are passed to std::format to form a custom extra message that is printed if the condition fails.

◆ debug_confirm_eq

#define debug_confirm_eq ( a,
b,
... )
Value:
void(0)

An confirmation macro that checks the equality of two values lhs and rhs.
On failure, the confirmation prints an error message and exits the program with a non-zero status code. The message always includes the source code location of the confirmation and a stringified version of the values that failed the equality check.

NOTE: The debug_confirm_eq macro expands to a no-op unless the DEBUG flag is set.

The first two arguments are the values to check for equality, the (optional) rest are passed to std::format to form a custom extra message that is printed if the values are not equal.