11#include "../macros.hpp"
12#include "debugger.hpp"
13#include "exception.hpp"
17hi_export_module(hikogui.utility.assert);
21hi_warning_ignore_msvc(26472);
23namespace hi {
inline namespace v1 {
31hi_export [[
nodiscard]]
constexpr bool bound_check(std::unsigned_integral
auto index, std::unsigned_integral
auto upper)
noexcept
33 using value_type = common_integer_t<
decltype(index),
decltype(upper)>;
35 hilet
index_ =
static_cast<value_type
>(index);
36 hilet
upper_ =
static_cast<value_type
>(upper);
40hi_export [[
nodiscard]]
constexpr bool bound_check(std::unsigned_integral
auto index, std::signed_integral
auto upper)
noexcept
56hi_export [[
nodiscard]]
constexpr bool bound_check(std::integral
auto index, std::integral
auto lower, std::integral
auto upper)
noexcept
58 using value_type = common_integer_t<
decltype(index),
decltype(lower),
decltype(upper)>;
60 auto index_ =
static_cast<value_type
>(index);
61 auto lower_ =
static_cast<value_type
>(lower);
62 auto upper_ =
static_cast<value_type
>(upper);
75template<
typename Context>
78 std::ranges::size(
range)
79 } -> std::unsigned_integral;
90 static_assert(
sizeof(index) <=
sizeof(
size_t));
92 if constexpr (std::is_signed_v<std::decay_t<
decltype(index)>>) {
98 return static_cast<size_t>(index) < std::ranges::size(
range);
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
hi_export constexpr bool bound_check(std::unsigned_integral auto index, std::unsigned_integral auto upper) noexcept
Check if an unsigned index is less than the bound.
Definition assert.hpp:31
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377