NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
contract.hpp
Go to the documentation of this file.
1
9#pragma once
10
11#include <cassert>
12
13#include "NNL/common/src_info.hpp" // IWYU pragma: export
21
35#ifdef NNL_THROW_ON_CONTRACT_VIOLATION
37#define NNL_EXPECTS(precondition) \
38 do { \
39 if (!static_cast<bool>(precondition)) { \
40 NNL_THROW(nnl::PreconditionError(NNL_SRCTAG("precondition failed: " #precondition))); \
41 } \
42 } while (false)
43#else
44#include "NNL/common/panic.hpp" // IWYU pragma: export
45#define NNL_EXPECTS(precondition) \
46 do { \
47 if (!static_cast<bool>(precondition)) { \
48 nnl::Panic(NNL_SRCTAG("precondition failed: " #precondition)); \
49 } \
50 } while (false)
51#endif
52
59#define NNL_EXPECTS_DBG(precondition) \
60 do { \
61 assert(precondition); \
62 } while (false)
63
72#define NNL_ENSURES_DBG(postcondition) \
73 do { \
74 assert(postcondition); \
75 } while (false)
76
Defines the library-wide exception hierarchy and error handling macros.
Provides functions to set up the callback for fatal library errors.