|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
Utility macros for EBGeometry. More...
#include <cstdarg>#include <cstdio>#include <cstdlib>#include <stdexcept>#include <string>#include "EBGeometry_GPU.hpp"

Go to the source code of this file.
Classes | |
| class | EBGeometry::RequireError |
| What a failed EBGEOMETRY_REQUIRE throws on the host inside a ThrowOnRequire scope: its message, as it would have been printed. More... | |
| class | EBGeometry::ThrowOnRequire |
| While an object of this class lives, a failed EBGEOMETRY_REQUIRE on this thread throws RequireError instead of aborting: for a program that builds objects from input it does not control (the .ebg reader), so that a bad value is an error it reports, not the end of the program. More... | |
Namespaces | |
| namespace | EBGeometry |
| Namespace containing all of EBGeometry's functionality. | |
Macros | |
| #define | EBGEOMETRY_REQUIRE(cond, ...) |
| Always-on check of user input and one-time host setup. | |
| #define | EBGEOMETRY_EXPECT(cond) ((void)0) |
| Runtime precondition assertion for EBGeometry. | |
Functions | |
| int & | EBGeometry::MacrosDetail::throwingScopes () noexcept |
| How many ThrowOnRequire scopes are open on this thread. | |
| void | EBGeometry::MacrosDetail::requireFailed (const char *a_cond, const char *a_file, const int a_line, const char *a_format,...) |
| A failed EBGEOMETRY_REQUIRE on the host: throws RequireError inside a ThrowOnRequire scope, prints and aborts otherwise. | |
Utility macros for EBGeometry.
| #define EBGEOMETRY_EXPECT | ( | cond | ) | ((void)0) |
Runtime precondition assertion for EBGeometry.
When EBGEOMETRY_ENABLE_ASSERTIONS is defined (e.g. via -DEBGEOMETRY_ENABLE_ASSERTIONS on the compiler command line, in CXXFLAGS for GNU Make, or via CMake's target_compile_definitions), this macro evaluates cond and, if it is false, prints a diagnostic message to stderr and calls std::abort().
When EBGEOMETRY_ENABLE_ASSERTIONS is not defined the macro expands to ((void)0): cond is not evaluated at all, so an assertion costs exactly nothing in release. A variable computed solely to be asserted is then unused and must be marked [[maybe_unused]] at its declaration. On a device (CUDA/HIP) compilation pass with assertions enabled the macro prints the failing expression with the device printf and traps, instead of std::fprintf / std::abort. Unlike assert(), this does not depend on NDEBUG, which Release configurations define.
| cond | Boolean-convertible expression to test. |
| #define EBGEOMETRY_REQUIRE | ( | cond, | |
| ... | |||
| ) |
Always-on check of user input and one-time host setup.
Evaluates cond in every build, whether or not EBGEOMETRY_ENABLE_ASSERTIONS is defined. If it is false, prints "EBGeometry::" followed by the formatted message, the failed condition, the file and the line to stderr, and calls std::abort(); inside a ThrowOnRequire scope, it throws RequireError with the message instead (host only).
The library uses two kinds of check:
EBGEOMETRY_EXPECT for internal invariants, including on hot paths such as a signed-distance query. It compiles to nothing unless assertions are enabled.EBGEOMETRY_REQUIRE for what a caller controls – constructor arguments, sizes and counts, memory resources – checked once, outside any query loop, where a Release build would otherwise continue into a wrong answer or undefined behavior. Its cost is a few comparisons per object built.The file readers do not abort on a bad file: they throw EBGeometry::Parser::ParseError.
The message is a printf format string literal, starting with the class or function that checks, followed by its arguments:
On a device compilation pass (CUDA/HIP) the macro prints only the failed condition, with the device printf, and traps.
| cond | Boolean-convertible expression to test. Always evaluated. |
| ... | A printf format string literal, then its arguments. |
|
inline |
A failed EBGEOMETRY_REQUIRE on the host: throws RequireError inside a ThrowOnRequire scope, prints and aborts otherwise.
One call at each check, out of line, so that a check adds no more code to the function it is in than a call (the message is formatted here, on failure only).
| [in] | a_cond | The failed condition. |
| [in] | a_file | The file. |
| [in] | a_line | The line. |
| [in] | a_format | The message, a printf format. |
| [in] | ... | Its arguments. |
|
inlinenoexcept |
How many ThrowOnRequire scopes are open on this thread.