mmcfilters
Public API documentation
Loading...
Searching...
No Matches
Macros | Enumerations | Variables
Contract.hpp File Reference

Compile-time policy for defensive checks at untrusted API boundaries. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MMCFILTERS_CONTRACT_UNCHECKED   0
 Compile-time value selecting a build without defensive boundary validation.
 
#define MMCFILTERS_CONTRACT_CHECKED   1
 Compile-time value selecting a build with defensive boundary validation.
 
#define MMCFILTERS_CONTRACT_MODE   MMCFILTERS_CONTRACT_CHECKED
 Contract mode selected for the current translation unit.
 
#define MMCFILTERS_CONTRACT_REQUIRE(condition, ...)
 Evaluates a caller precondition and its failure action only in checked builds.
 
#define MMCFILTERS_CONTRACT_CHECKED_ONLY(...)
 Executes validation statements only when defensive checks are enabled.
 

Enumerations

enum class  mmcfilters::contract::Mode { Unchecked = MMCFILTERS_CONTRACT_UNCHECKED , Checked = MMCFILTERS_CONTRACT_CHECKED }
 Available compile-time policies for defensive API-boundary validation. More...
 

Variables

constexpr Mode mmcfilters::contract::mode = static_cast<Mode>(MMCFILTERS_CONTRACT_MODE)
 Contract policy selected when this translation unit was compiled.
 
constexpr bool mmcfilters::contract::validationsEnabled = mode == Mode::Checked
 Whether defensive API-boundary validation is enabled in this build.
 

Detailed Description

Compile-time policy for defensive checks at untrusted API boundaries.

Public signatures are independent of the selected mode. Checked builds reject invalid caller input; unchecked builds discard those boundary checks for controlled scientific benchmarks. Internal kernels must not use these macros: they are entered only after their caller established the required domains.

Definition in file Contract.hpp.

Macro Definition Documentation

◆ MMCFILTERS_CONTRACT_CHECKED

#define MMCFILTERS_CONTRACT_CHECKED   1

Compile-time value selecting a build with defensive boundary validation.

Definition at line 18 of file Contract.hpp.

◆ MMCFILTERS_CONTRACT_CHECKED_ONLY

#define MMCFILTERS_CONTRACT_CHECKED_ONLY (   ...)
Value:
do { \
if constexpr (::mmcfilters::contract::validationsEnabled) { \
__VA_ARGS__; \
} \
} while (false)

Executes validation statements only when defensive checks are enabled.

Parameters
...Validation statements omitted from unchecked builds.

Definition at line 67 of file Contract.hpp.

◆ MMCFILTERS_CONTRACT_MODE

#define MMCFILTERS_CONTRACT_MODE   MMCFILTERS_CONTRACT_CHECKED

Contract mode selected for the current translation unit.

Definition at line 22 of file Contract.hpp.

◆ MMCFILTERS_CONTRACT_REQUIRE

#define MMCFILTERS_CONTRACT_REQUIRE (   condition,
  ... 
)
Value:
do { \
if constexpr (::mmcfilters::contract::validationsEnabled) { \
if (!(condition)) { \
__VA_ARGS__; \
} \
} \
} while (false)

Evaluates a caller precondition and its failure action only in checked builds.

Parameters
conditionBoolean caller precondition established at the public API boundary.
...Statements that report or handle a failed precondition.

Definition at line 53 of file Contract.hpp.

◆ MMCFILTERS_CONTRACT_UNCHECKED

#define MMCFILTERS_CONTRACT_UNCHECKED   0

Compile-time value selecting a build without defensive boundary validation.

Definition at line 15 of file Contract.hpp.

Enumeration Type Documentation

◆ Mode

enum class mmcfilters::contract::Mode
strong

Available compile-time policies for defensive API-boundary validation.

Enumerator
Unchecked 

Caller-established preconditions are trusted without defensive checks.

Checked 

Public boundaries validate caller-provided preconditions.

Definition at line 32 of file Contract.hpp.

Variable Documentation

◆ mode

constexpr Mode mmcfilters::contract::mode = static_cast<Mode>(MMCFILTERS_CONTRACT_MODE)
inlineconstexpr

Contract policy selected when this translation unit was compiled.

Definition at line 40 of file Contract.hpp.

◆ validationsEnabled

constexpr bool mmcfilters::contract::validationsEnabled = mode == Mode::Checked
inlineconstexpr

Whether defensive API-boundary validation is enabled in this build.

Definition at line 43 of file Contract.hpp.