|
|
@ -114,9 +114,6 @@ namespace gp_config{ |
|
|
|
*/ |
|
|
|
constexpr bool has_buffer_bounds = true; |
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
/**
|
|
|
|
* @brief A value used to determine the strength used by random number generators |
|
|
|
* |
|
|
@ -129,7 +126,7 @@ namespace gp_config{ |
|
|
|
/**
|
|
|
|
* @brief an exception that represents an assertion failure |
|
|
|
*/ |
|
|
|
struct assert_failure{ |
|
|
|
struct assert_failure : std::exception { |
|
|
|
assert_failure(const char* reason) |
|
|
|
: what_str{reason} |
|
|
|
{} |
|
|
@ -141,15 +138,28 @@ namespace gp_config{ |
|
|
|
* @brief UNUSED |
|
|
|
*/ |
|
|
|
constexpr size_t assert_buffer_size = 0; |
|
|
|
|
|
|
|
constexpr auto fail = [] [[noreturn]] (auto reason) noexcept(not has_exceptions) { |
|
|
|
if constexpr (has_exceptions) { |
|
|
|
throw assert_failure(reason); |
|
|
|
} else { |
|
|
|
volatile uint8_t n = 0; |
|
|
|
{ |
|
|
|
failure_point: |
|
|
|
n = n + 1; |
|
|
|
goto failure_point; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief an assertion function |
|
|
|
*/ |
|
|
|
constexpr auto assertion = [](bool pred, const char* reason) -> void{ |
|
|
|
constexpr auto assertion = [](bool pred, const char* reason) |
|
|
|
noexcept(std::is_nothrow_invocable_v<decltype(fail), decltype(reason)>) -> void { |
|
|
|
if(!pred) { |
|
|
|
log_failure(reason); |
|
|
|
if constexpr (has_exceptions) |
|
|
|
throw assert_failure(reason); |
|
|
|
fail(reason); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|