IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
nindex.hxx
Go to the documentation of this file.
1
3
4#pragma once
6
7namespace ice
8{
9
10 struct nindex_invalid_t;
11
12 struct nindex : public ice::nvalue
13 {
16 using ice::nvalue::operator==;
17
18 // support for allocation sizes
19 constexpr auto offset(this nindex self) noexcept -> ice::isize;
20
21 constexpr nindex() noexcept = default;
22 constexpr nindex(nvalue value) noexcept;
23 constexpr nindex(base_type value) noexcept;
24 constexpr nindex(base_type value, base_type width) noexcept;
25
26 // special operators
27 constexpr bool operator==(this ncount self, nindex_invalid_t) noexcept;
28 };
29
31
32 inline constexpr auto nindex::offset(this nindex self) noexcept -> ice::isize
33 {
34 return { self._value * static_cast<ice::isize::base_type>(self._width) };
35 }
36
37 inline constexpr nindex::nindex(nvalue value) noexcept
38 : nvalue{ value._width, value._value }
39 { }
40
41 inline constexpr nindex::nindex(base_type value) noexcept
42 : nvalue{ 1, static_cast<base_signed_type>(value) }
43 { }
44
45 inline constexpr nindex::nindex(base_type value, base_type width) noexcept
46 : nvalue{ width, static_cast<base_signed_type>(value) }
47 { }
48
49 inline constexpr bool nindex::operator==(this ncount self, nindex_invalid_t) noexcept
50 {
51 return self._width == 0;
52 }
53
57
58 constexpr auto operator""_index(unsigned long long value) noexcept -> ice::nindex
59 {
60 return ice::nindex{ value };
61 }
62
63} // namespace ice
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
SPDX-License-Identifier: MIT.
Definition array.hxx:12
static constexpr ice::nindex nindex_min
Definition nindex.hxx:55
static constexpr ice::nindex_invalid_t nindex_none
Definition nindex.hxx:56
static constexpr ice::nindex nindex_max
Definition nindex.hxx:54
Represents a signed size value on the given platform.
Definition mem_size_types.hxx:14
std::conditional_t< ice::build::is_x64, ice::i64, ice::i32 > base_type
Definition mem_size_types.hxx:16
Definition ncount.hxx:14
Definition nindex.hxx:30
Definition nindex.hxx:13
ice::detail::nvalue_base_stype base_signed_type
Definition nvalue.hxx:76
constexpr bool operator==(this ncount self, nindex_invalid_t) noexcept
Definition nindex.hxx:49
constexpr auto offset(this nindex self) noexcept -> ice::isize
Definition nindex.hxx:32
constexpr nindex() noexcept=default
ice::detail::nvalue_base_utype base_type
Definition nvalue.hxx:75
Definition nvalue.hxx:74
ice::detail::nvalue_base_stype base_signed_type
Definition nvalue.hxx:76
ice::detail::nvalue_base_utype base_type
Definition nvalue.hxx:75