12#include "../macros.hpp"
13#include "exception.hpp"
17hi_export_module(hikogui.utility.assert);
21hi_warning_ignore_msvc(26472);
23hi_export
namespace hi {
inline namespace v1 {
31hi_export [[nodiscard]]
constexpr bool bound_check(std::integral
auto index, std::integral
auto upper)
noexcept
33 return std::cmp_less(index, upper);
44hi_export [[nodiscard]]
constexpr bool bound_check(std::integral
auto index, std::integral
auto lower, std::integral
auto upper)
noexcept
47 if (std::cmp_greater(lower, upper)) {
48 hi_assert_abort(
"bound_check() lower is greater than upper.");
51 hi_assume(std::cmp_less_equal(lower, upper));
54 return std::cmp_greater_equal(index, lower) and std::cmp_less(index, upper);
65hi_export [[nodiscard]]
constexpr bool bound_check(std::floating_point
auto index, std::floating_point
auto lower, std::floating_point
auto upper)
noexcept
69 hi_assert_abort(
"bound_check() lower is greater than upper.");
72 hi_assume(lower <= upper);
75 return index >= lower and index <= upper;
78template<
typename Context>
81 std::ranges::size(range)
82 } -> std::unsigned_integral;
91hi_export [[nodiscard]]
constexpr bool bound_check(std::integral
auto index, bound_check_range_helper
auto&& range)
noexcept
93 static_assert(
sizeof(index) <=
sizeof(
size_t));
95 if constexpr (std::is_signed_v<std::decay_t<
decltype(index)>>) {
101 return static_cast<size_t>(index) < std::ranges::size(range);
Utilities for throwing exceptions and terminating the application.
The HikoGUI namespace.
Definition array_generic.hpp:20
hi_export constexpr bool bound_check(std::integral auto index, std::integral auto upper) noexcept
Check if an index is less than the bound.
Definition assert.hpp:31
DOXYGEN BUG.
Definition algorithm_misc.hpp:20