|
HikoGUI
A low latency retained GUI
|
Utilities to assert and bound check. More...
#include "architecture.hpp"#include "debugger.hpp"#include "utility.hpp"#include "type_traits.hpp"#include "exception.hpp"#include <exception>#include <ranges>Go to the source code of this file.
Namespaces | |
| namespace | hi |
| geometry/margins.hpp | |
| namespace | hi::v1 |
| The HikoGUI API version 1. | |
Concepts | |
| concept | hi::v1::bound_check_range_helper |
Macros | |
| #define | hi_assert(expression, ...) |
| Assert if expression is true. | |
| #define | hi_assert_or_return(x, y) |
| Assert if an expression is true. | |
| #define | hi_assert_bounds(x, ...) |
| #define | hi_assert_not_null(x, ...) |
| Assert if an expression is not nullptr. | |
| #define | hi_axiom(expression, ...) hi_assert(expression __VA_OPT__(, ) __VA_ARGS__) |
| Specify an axiom; an expression that is true. | |
| #define | hi_axiom_not_null(expression, ...) hi_assert_not_null(expression __VA_OPT__(, ) __VA_ARGS__) |
| Assert if an expression is not nullptr. | |
| #define | hi_no_default(...) [[unlikely]] hi_debug_abort("Reached no-default:" __VA_ARGS__) |
| This part of the code should not be reachable, unless a programming bug. | |
| #define | hi_static_no_default(...) |
| This part of the code should not be reachable, unless a programming bug. | |
| #define | hi_not_implemented(...) [[unlikely]] hi_debug_abort("Not implemented: " __VA_ARGS__); |
| This part of the code has not been implemented yet. | |
| #define | hi_static_not_implemented(...) hi_static_no_default("Not implemented: " __VA_ARGS__) |
| This part of the code has not been implemented yet. | |
Functions | |
| constexpr bool | hi::v1::bound_check (std::unsigned_integral auto index, std::unsigned_integral auto upper) noexcept |
| Check if an unsigned index is less than the bound. | |
| constexpr bool | hi::v1::bound_check (std::integral auto index, std::integral auto lower, std::integral auto upper) noexcept |
| Check if an index is between the lower (inclusive) and upper (exclusive). | |
| constexpr bool | hi::v1::bound_check (std::integral auto index, bound_check_range_helper auto &&range) noexcept |
| Check if an index is within a range. | |
Utilities to assert and bound check.
| #define hi_assert | ( | expression, | |
| ... ) |
Assert if expression is true.
Independent of built type this macro will always check and abort on fail.
| expression | The expression to test. |
| ... | A string-literal explaining the reason why this assert exists. |
| #define hi_assert_bounds | ( | x, | |
| ... ) |
| #define hi_assert_not_null | ( | x, | |
| ... ) |
Assert if an expression is not nullptr.
If the expression is not a nullptr then return from the function.
| x | The expression to test |
| ... | A string-literal as the reason why the not-null check exists. |
| #define hi_assert_or_return | ( | x, | |
| y ) |
Assert if an expression is true.
If the expression is false then return from the function.
| x | The expression to test |
| y | The value to return from the current function. |
| #define hi_axiom | ( | expression, | |
| ... ) hi_assert(expression __VA_OPT__(, ) __VA_ARGS__) |
Specify an axiom; an expression that is true.
An axiom is checked in debug mode, and is used as an optimization in release mode.
| expression | The expression that is true. |
| ... | A string-literal as the reason why the axiom exists. |
| #define hi_axiom_not_null | ( | expression, | |
| ... ) hi_assert_not_null(expression __VA_OPT__(, ) __VA_ARGS__) |
Assert if an expression is not nullptr.
If the expression is not a nullptr then return from the function.
| x | The expression to test |
| ... | A string-literal as the reason why the not-null check exists. |
| #define hi_no_default | ( | ... | ) | [[unlikely]] hi_debug_abort("Reached no-default:" __VA_ARGS__) |
This part of the code should not be reachable, unless a programming bug.
This function should be used in unreachable else statements or switch-default labels,
| ... | A string-literal as the reason why the no-default exists. |
| #define hi_not_implemented | ( | ... | ) | [[unlikely]] hi_debug_abort("Not implemented: " __VA_ARGS__); |
This part of the code has not been implemented yet.
This aborts the program.
| ... | A string-literal as the reason why this it not implemented. |
| #define hi_static_no_default | ( | ... | ) |
This part of the code should not be reachable, unless a programming bug.
This function should be used in unreachable constexpr else statements.
| ... | A string-literal as the reason why the no-default exists. |
| #define hi_static_not_implemented | ( | ... | ) | hi_static_no_default("Not implemented: " __VA_ARGS__) |
This part of the code has not been implemented yet.
This function should be used in unreachable constexpr else statements.
| ... | A string-literal as the reason why this it not implemented. |