NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
Contracts

Defines macros for Design-by-Contract verification. More...

Macros

#define NNL_EXPECTS(precondition)
 A precondition check.
#define NNL_EXPECTS_DBG(precondition)
 Debug-only precondition check.
#define NNL_ENSURES_DBG(postcondition)
 Debug-only postcondition check.

Detailed Description

Defines macros for Design-by-Contract verification.

See also
NNL_EXPECTS
NNL_EXPECTS_DBG
NNL_ENSURES_DBG

Macro Definition Documentation

◆ NNL_ENSURES_DBG

#define NNL_ENSURES_DBG ( postcondition)
Value:
do { \
assert(postcondition); \
} while (false)

Debug-only postcondition check.

This macro is used to check requirements that must hold true after the function executes. The function itself is responsible for ensuring these conditions, assuming all preconditions were met; failure indicates a bug in the function.

◆ NNL_EXPECTS

#define NNL_EXPECTS ( precondition)
Value:
do { \
if (!static_cast<bool>(precondition)) { \
nnl::Panic(NNL_SRCTAG("precondition failed: " #precondition)); \
} \
} while (false)

A precondition check.

This macro is used to check requirements that must hold true before the function is called. The caller must ensure these conditions; failure typically indicates an error in the calling code.

Note
By default, this macro terminates execution via a configurable callback. If the CMake option NNL_THROW_ON_CONTRACT_VIOLATION is enabled, it throws nnl::PreconditionError instead.
See also
nnl::SetGlobalPanicCB

◆ NNL_EXPECTS_DBG

#define NNL_EXPECTS_DBG ( precondition)
Value:
do { \
assert(precondition); \
} while (false)

Debug-only precondition check.

See also
NNL_EXPECTS