Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
contract.hpp File Reference

Go to the source code of this file.

Macro Definition Documentation

◆ ARENE_INTERNAL_CONTRACT_CHECK

#define ARENE_INTERNAL_CONTRACT_CHECK ( violation_type,
message,
condition )
Value:
/*NOLINT*/ \
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
if (ARENE_EXPECT((condition))) { \
} else { \
ARENE_INTERNAL_CONTRACT_VIOLATION(violation_type, (message)); \
} \
} while (false)
#define ARENE_EXPECT(...)
A macro to use in an if statement to declare that the expression is expected to be true more often th...
Definition expect.hpp:56

Check if a contract condition is true and call the violation handler if not.

Parameters
violation_typeThe type of contract being checked
messageThe message to report if the condition is not true
conditionThe condition to check

◆ ARENE_INTERNAL_CONTRACT_VIOLATION

#define ARENE_INTERNAL_CONTRACT_VIOLATION ( violation_type,
message )
Value:
/*! @brief A class to provide information about the contract violation */ \
class arene_contract_info_wrapper { \
public: \
/*! @brief Return information about the contract violation */ \
static constexpr auto arene_contract_make_info() noexcept \
-> ::arene::base::contract_detail::contract_violation_info { \
return { \
static_cast<::arene::base::detail::raw_c_string>(__FILE__), \
static_cast<::arene::base::detail::raw_c_string>(ARENE_STRINGIZE(__LINE__)), \
static_cast<::arene::base::detail::raw_c_string>(message), \
::arene::base::contract_detail::contract_type::violation_type \
}; \
} \
}; \
::arene::base::contract_detail::contract_violation_wrapper( \
::arene::base::contract_detail::info_holder<arene_contract_info_wrapper>::value \
)
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10
#define ARENE_STRINGIZE(...)
Definition stringize.hpp:31

Call the contract violation handler for a violated contract.

Parameters
violation_typeThe type of contract violated
messageThe violation message

◆ ARENE_INVARIANT

#define ARENE_INVARIANT ( condition)

Check that an invariant holds, and terminate the application if it does not.

Parameters
conditionThe macro arguments must be a single expression that can be contextually converted to bool. The invariant holds if the expression evaluates to true.

◆ ARENE_INVARIANT_UNREACHABLE

#define ARENE_INVARIANT_UNREACHABLE ( message)

Terminate the application if this line is ever executed. The supplied message will be output in that case.

Parameters
messageThe message to output

◆ ARENE_PRECONDITION

#define ARENE_PRECONDITION ( condition)

Check that a precondition holds, and terminate the application if it does not.

Parameters
conditionThe macro arguments must be a single expression that can be contextually converted to bool. The precondition holds if the expression evaluates to true.