12#include "exception.hpp"
15namespace hi::inline
v1 {
17[[nodiscard]]
bool bound_check(
18 std::unsigned_integral
auto index,
19 std::unsigned_integral
auto upper)
noexcept
23 auto index_ =
static_cast<value_type
>(index);
24 auto upper_ =
static_cast<value_type
>(upper);
25 return index_ < upper_;
28[[nodiscard]]
bool bound_check(
29 std::integral
auto index,
30 std::integral
auto lower,
31 std::integral
auto upper)
noexcept
33 using value_type =
common_integer_t<
decltype(index),
decltype(lower),
decltype(upper)>;
35 auto index_ =
static_cast<value_type
>(index);
36 auto lower_ =
static_cast<value_type
>(lower);
37 auto upper_ =
static_cast<value_type
>(upper);
39 return index_ >= lower_ and index_ < upper_;
47#define hi_assert(expression) \
49 if (not(expression)) { \
60#define hi_assert_or_return(x, y) \
62 [[unlikely]] return y; \
65#define hi_bounds(x, ...) \
67 if (not bound_check(x, __VA_ARGS__) { \
80#define hi_axiom(expression) hi_assert(expression)
85#define hi_no_default() [[unlikely]] hi_debug_abort()
94#define hi_axiom(expression) hi_assume(expression)
99#define hi_no_default() hi_unreachable()
105#define hi_static_no_default() \
106 []<bool Flag = false>() \
108 static_assert(Flag); \
115#define hi_not_implemented() [[unlikely]] hi_debug_abort();
120#define hi_static_not_implemented() hi_static_no_default()
Utilities used by the HikoGUI library itself.
Functions and macros for handling architectural difference between compilers, CPUs and operating syst...
DOXYGEN BUG.
Definition algorithm.hpp:15
common_integer< L, R... >::type common_integer_t
Get an integer type that will fit all values from all template parameters.
Definition type_traits.hpp:304