Declaration of our assertion macros.
|
| template<size_t AssertionStringSize, size_t FileStringSize, size_t LineStringSize> |
| std::string | mundy::get_throw_require_host_string (const StringLiteral< AssertionStringSize > &assertion_string, const std::string &message_to_print, const StringLiteral< FileStringSize > &file_string=make_string_literal("/home/runner/work/MuNDy/MuNDy/mundy/core/utils/src/mundy_utils/throw_assert.hpp"), const StringLiteral< LineStringSize > &line_string=make_string_literal(MUNDY_LINE_STRING)) |
| template<size_t AssertionStringSize, size_t MessageStringSize, size_t FileStringSize, size_t LineStringSize> |
| std::string | mundy::get_throw_require_host_string (const StringLiteral< AssertionStringSize > &assertion_string, const char(&message_to_print)[MessageStringSize], const StringLiteral< FileStringSize > &file_string=make_string_literal("/home/runner/work/MuNDy/MuNDy/mundy/core/utils/src/mundy_utils/throw_assert.hpp"), const StringLiteral< LineStringSize > &line_string=make_string_literal(MUNDY_LINE_STRING)) |
| template<size_t AssertionStringSize, size_t MessageStringSize, size_t FileStringSize, size_t LineStringSize> |
| std::string | mundy::get_throw_require_host_string (const StringLiteral< AssertionStringSize > &assertion_string, const StringLiteral< MessageStringSize > &message_to_print, const StringLiteral< FileStringSize > &file_string=make_string_literal("/home/runner/work/MuNDy/MuNDy/mundy/core/utils/src/mundy_utils/throw_assert.hpp"), const StringLiteral< LineStringSize > &line_string=make_string_literal(MUNDY_LINE_STRING)) |
| template<size_t AssertionStringSize, AnyStringSink MessageStringType, size_t FileStringSize, size_t LineStringSize> |
| std::string | mundy::get_throw_require_host_string (const StringLiteral< AssertionStringSize > &assertion_string, const MessageStringType &message_to_print, const StringLiteral< FileStringSize > &file_string=make_string_literal("/home/runner/work/MuNDy/MuNDy/mundy/core/utils/src/mundy_utils/throw_assert.hpp"), const StringLiteral< LineStringSize > &line_string=make_string_literal(MUNDY_LINE_STRING)) |
| template<size_t AssertionStringSize, size_t MessageStringSize, size_t FileStringSize, size_t LineStringSize> |
| constexpr auto | mundy::get_throw_require_device_string (const StringLiteral< AssertionStringSize > &assertion_string, const char(&message_to_print)[MessageStringSize], const StringLiteral< FileStringSize > &file_string=make_string_literal("/home/runner/work/MuNDy/MuNDy/mundy/core/utils/src/mundy_utils/throw_assert.hpp"), const StringLiteral< LineStringSize > &line_string=make_string_literal(MUNDY_LINE_STRING)) |
| template<size_t AssertionStringSize, size_t MessageStringSize, size_t FileStringSize, size_t LineStringSize> |
| constexpr auto | mundy::get_throw_require_device_string (const StringLiteral< AssertionStringSize > &assertion_string, const StringLiteral< MessageStringSize > &message_to_print, const StringLiteral< FileStringSize > &file_string=make_string_literal("/home/runner/work/MuNDy/MuNDy/mundy/core/utils/src/mundy_utils/throw_assert.hpp"), const StringLiteral< LineStringSize > &line_string=make_string_literal(MUNDY_LINE_STRING)) |
| template<size_t AssertionStringSize, CompileTimeStringSink MessageStringType, size_t FileStringSize, size_t LineStringSize> |
| constexpr auto | mundy::get_throw_require_device_string (const StringLiteral< AssertionStringSize > &assertion_string, const MessageStringType &message_to_print, const StringLiteral< FileStringSize > &file_string=make_string_literal("/home/runner/work/MuNDy/MuNDy/mundy/core/utils/src/mundy_utils/throw_assert.hpp"), const StringLiteral< LineStringSize > &line_string=make_string_literal(MUNDY_LINE_STRING)) |
| template<typename ExceptionType, typename MessageStringType, size_t AssertionStringSize, size_t FileStringSize, size_t LineStringSize> |
| constexpr void | mundy::throw_require (const bool assertion_value, const StringLiteral< AssertionStringSize > &assertion_string, const MessageStringType &message_to_print, const StringLiteral< FileStringSize > &file_string=make_string_literal("/home/runner/work/MuNDy/MuNDy/mundy/core/utils/src/mundy_utils/throw_assert.hpp"), const StringLiteral< LineStringSize > &line_string=make_string_literal(MUNDY_LINE_STRING)) |
| template<typename MessageStringType, size_t AssertionStringSize, size_t FileStringSize, size_t LineStringSize> |
| constexpr void | mundy::abort_require (const bool assertion_value, const StringLiteral< AssertionStringSize > &assertion_string, const MessageStringType &message_to_print, const StringLiteral< FileStringSize > &file_string=make_string_literal("/home/runner/work/MuNDy/MuNDy/mundy/core/utils/src/mundy_utils/throw_assert.hpp"), const StringLiteral< LineStringSize > &line_string=make_string_literal(MUNDY_LINE_STRING)) |
| #define MUNDY_THROW_REQUIRE |
( |
| assertion_to_test, |
|
|
| exception_to_throw, |
|
|
| message_to_print ) |
Value:do { \
KOKKOS_IF_ON_HOST(MUNDY_THROW_REQUIRE_HOST(assertion_to_test, exception_to_throw, message_to_print);) \
KOKKOS_IF_ON_DEVICE(MUNDY_THROW_REQUIRE_DEVICE(assertion_to_test, exception_to_throw, message_to_print);) \
} while (false);
- Note
- This macro will always test the assertion, regardless of whether NDEBUG is defined. Use it to enforce critical requirements (hence the name).
Host and device compatible. The two differ heavily in that host can print the function name, while device cannot. The host code will throw the given exception, while the device code will abort. The abort is unavoidable, as device code cannot throw exceptions.
Message types: On the host, the message may be a string literal, std::string, mundy::StringLiteral, or a sink expression such as mundy::sink() << "Failure for a = " << a. On the device, only compile-time messages can be printed in full. That includes string literals, mundy::StringLiteral, and literal-only sinks such as mundy::sink() << "left " << "right". Other message types still abort, but they fall back to file and line information plus a generic note.
- Parameters
-
| assertion_to_test | The assertion to test |
| exception_to_throw | The exception to throw if the assertion is false (will only be thrown on the host) |
| message_to_print | The message to print if the assertion is false |