39 or std::is_same_v<T, ice::nvalue>
40 or std::is_same_v<T, ice::ncount>
41 or std::is_same_v<T, ice::nindex>;
45#if ISP_ARCH_BITS == 64
46#define ICE_NVALUE_VALUE_MAX 0x0000'7fff'ffff'ffff
47#define ICE_NVALUE_VALUE_FIELD_BITS : 48
48#define ICE_NVALUE_WIDTH_FIELD_BITS : 16
52#elif ISP_ARCH_BITS == 32
53#define ICE_NVALUE_VALUE_MAX 0xffff'ffff
54#define ICE_NVALUE_VALUE_FIELD_BITS
55#define ICE_NVALUE_WIDTH_FIELD_BITS
60# error Unhandled architecture!
70 return ICE_NVALUE_VALUE_MAX;
85 template<
typename Self>
86 constexpr bool is_valid(
this Self self)
noexcept {
return static_cast<bool>(self._width); }
88 template<
typename Self>
91 return self.is_valid() ?
static_cast<std::remove_reference_t<decltype(fallback)
>>(self.native()) : fallback;
94 template<
typename Self>
101 using ResultType = std::remove_reference_t<
decltype(fallback)>;
103 ResultType
const second_value =
static_cast<ResultType
>(other);
104 return self.is_valid() ?
ice::min<ResultType>(
static_cast<ResultType
>(self.native()), second_value) : fallback;
109 constexpr auto native() const noexcept {
return static_cast<base_type>(_value * (_width != 0)); }
117#if ISP_WEBAPP || ISP_UNIX
119 constexpr operator base_type() const noexcept {
return this->native(); }
130 template<
typename Self>
133 template<
typename Self>
136 )
noexcept -> std::strong_ordering;
139 template<
typename Self>
140 constexpr auto operator++(
this Self& self)
noexcept -> Self&;
142 template<
typename Self>
143 constexpr auto operator++(
this Self& self,
int)
noexcept -> Self;
145 template<
typename Self>
146 constexpr auto operator--(
this Self& self)
noexcept -> Self&;
148 template<
typename Self>
149 constexpr auto operator--(
this Self& self,
int)
noexcept -> Self;
152 template<
typename Self>
155 template<
typename Self>
158 template<
typename Self>
161 template<
typename Self>
164 template<
typename Self>
167 template<
typename Self>
170 template<
typename Self>
173 template<
typename Self>
177 template<
typename Self>
182 if constexpr (std::is_base_of_v<
ice::nvalue,
decltype(other)>)
185 return self.is_valid() == other.is_valid() && (self.is_valid() ==
false || self.native() == other.native());
187 return static_cast<bool>((self._width * other._width) * (self._value == other._value) + ((self._width + other._width) == 0));
192 return self.native() == other;
197 static_assert(
nvalue{0, 0} == nvalue{0, 0},
"Invalid values are equal to each other");
198 static_assert(nvalue{0, 1} == nvalue{0, 1},
"Invalid values are equal to each other ('_value' is not '0')");
199 static_assert(nvalue{1, 0} == nvalue{1, 0},
"Valid values are equal if '_value' is the same.");
200 static_assert(nvalue{1, 4} == nvalue{2, 4},
"Valid values are equal if '_value' is the same. ('_width' differs)");
201 static_assert(nvalue{1, 0} != nvalue{0, 0},
"Valid values are not equal to invalid values. ('_value' is '0' in both)");
202 static_assert(nvalue{1, 0} != nvalue{1, 1},
"Valid values are not equal if '_value' differs ('_width' is '1' in both)");
203 static_assert(nvalue{1, 1} != nvalue{2, 2},
"Valid values are not equal if '_value' differs ('_width' and '_value' differs)");
205 template<
typename Self>
208 )
noexcept -> std::strong_ordering
210 if constexpr (std::is_base_of_v<
ice::nvalue,
decltype(other)>)
212 return self.internal() <=> other.internal();
221 template<
typename Self>
228 template<
typename Self>
231 const Self old = self;
236 template<
typename Self>
243 template<
typename Self>
246 const Self old = self;
252 template<
typename Self>
260 template<
typename Self>
268 template<
typename Self>
276 template<
typename Self>
284 template<
typename Self>
293 template<
typename Self>
302 template<
typename Self>
311 template<
typename Self>
Definition container_concepts.hxx:12
Definition hashmap_details.hxx:13
consteval auto nvalue_min_value() noexcept -> ice::detail::nvalue_base_utype
Definition nvalue.hxx:63
consteval auto nvalue_max_value() noexcept -> ice::detail::nvalue_base_utype
Definition nvalue.hxx:68
ice::usize::base_type nvalue_base_utype
Definition nvalue.hxx:16
ice::isize::base_type nvalue_base_stype
Definition nvalue.hxx:17
constexpr auto min(arr_t< Size, T > left, arr_t< Size, U > right) noexcept -> arr_t< Size, T >
Definition array_operations.hxx:60
SPDX-License-Identifier: MIT.
Definition array.hxx:12
std::uint64_t u64
Definition types.hxx:27
std::uint16_t u16
Definition types.hxx:25
std::uint32_t u32
Definition types.hxx:26
std::uint8_t u8
Definition types.hxx:24
std::conditional_t< ice::build::is_x64, ice::i64, ice::i32 > base_type
Definition mem_size_types.hxx:16
constexpr bool operator==(this ncount self, ncount_invalid_t) noexcept
Definition ncount.hxx:53
ice::detail::nvalue_base_stype base_signed_type
Definition nvalue.hxx:76
constexpr auto operator/=(this Self &self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self &
Definition nvalue.hxx:312
constexpr auto operator--(this Self &self) noexcept -> Self &
Definition nvalue.hxx:237
constexpr auto u16() const noexcept
Definition nvalue.hxx:112
constexpr auto min_value_or(this Self self, ice::concepts::NValueCompatibleType auto other, ice::concepts::NValueCompatibleType auto fallback) noexcept
Definition nvalue.hxx:95
constexpr auto operator-=(this Self &self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self &
Definition nvalue.hxx:294
constexpr auto u32() const noexcept
Definition nvalue.hxx:113
constexpr auto operator/(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self
Definition nvalue.hxx:277
constexpr auto operator-(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self
Definition nvalue.hxx:261
constexpr auto operator++(this Self &self) noexcept -> Self &
Definition nvalue.hxx:222
constexpr auto internal() const noexcept
Definition nvalue.hxx:110
constexpr auto u64() const noexcept
Definition nvalue.hxx:114
constexpr auto operator<=>(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> std::strong_ordering
Definition nvalue.hxx:206
constexpr auto operator+=(this Self &self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self &
Definition nvalue.hxx:285
constexpr auto u8() const noexcept
Definition nvalue.hxx:111
constexpr bool operator==(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept
Definition nvalue.hxx:178
ice::detail::nvalue_base_utype _width ICE_NVALUE_WIDTH_FIELD_BITS
Definition nvalue.hxx:81
constexpr auto operator*=(this Self &self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self &
Definition nvalue.hxx:303
constexpr auto operator*(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self
Definition nvalue.hxx:269
constexpr bool is_valid(this Self self) noexcept
Definition nvalue.hxx:86
constexpr auto native() const noexcept
Definition nvalue.hxx:109
constexpr auto operator+(this Self self, ice::concepts::NValueCompatibleType auto other) noexcept -> Self
Definition nvalue.hxx:253
ice::detail::nvalue_base_utype base_type
Definition nvalue.hxx:75
constexpr auto value_or(this Self self, ice::concepts::NValueCompatibleType auto fallback) noexcept
Definition nvalue.hxx:89
ice::detail::nvalue_base_stype _value ICE_NVALUE_VALUE_FIELD_BITS
Definition nvalue.hxx:82
std::size_t base_type
Definition mem_size_types.hxx:28