IceShard
1
A personal game engine project, with development focused on 2D/2.5D games.
Toggle main menu visibility
Loading...
Searching...
No Matches
collections
public
ice
types
ncount.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/mem.hxx
>
6
#include <
ice/types/nvalue.hxx
>
7
8
namespace
ice
9
{
10
11
struct
ncount_invalid_t
;
12
13
struct
ncount
:
public
ice::nvalue
14
{
15
using
nvalue::base_type
;
16
using
nvalue::base_signed_type
;
17
using
ice::nvalue::operator==;
18
19
// support for allocation sizes
20
constexpr
auto
bytes
(
this
ncount
self)
noexcept
->
ice::usize
;
21
22
constexpr
ncount
() noexcept = default;
23
constexpr
ncount
(
nvalue
value) noexcept;
24
constexpr
ncount
(
base_type
value) noexcept;
25
constexpr
ncount
(
base_type
value,
base_type
width) noexcept;
26
27
// special operators
28
constexpr
bool
operator==(this
ncount
self,
ncount_invalid_t
) noexcept;
29
30
// implicit type conversions
31
constexpr operator
ice
::
usize
(this
ncount
self) noexcept {
return
self.bytes(); }
32
};
33
34
struct
ncount_invalid_t
:
ncount
{};
35
36
inline
constexpr
auto
ncount::bytes
(
this
ncount
self)
noexcept
->
ice::usize
37
{
38
return
{
static_cast<
ice::usize::base_type
>
(std::max<base_signed_type>(self._value, 0)) * self._width };
39
}
40
41
inline
constexpr
ncount::ncount
(
nvalue
value) noexcept
42
:
nvalue
{ value._width, value._value }
43
{ }
44
45
inline
constexpr
ncount::ncount
(
base_type
value) noexcept
46
:
nvalue
{ 1,
static_cast<
base_signed_type
>
(value) }
47
{ }
48
49
inline
constexpr
ncount::ncount
(
base_type
value,
base_type
width) noexcept
50
:
nvalue
{ width,
static_cast<
base_signed_type
>
(value) }
51
{ }
52
53
inline
constexpr
bool
ncount::operator==
(
this
ncount
self,
ncount_invalid_t
)
noexcept
54
{
55
return
self._width == 0;
56
}
57
58
static
constexpr
ice::ncount
ncount_max
{
ice::detail::nvalue_max_value
() };
59
static
constexpr
ice::ncount
ncount_min
{
ice::detail::nvalue_min_value
() };
60
static
constexpr
ice::ncount_invalid_t
ncount_none
{ };
61
62
constexpr
auto
operator
""
_count(
unsigned
long
long
value)
noexcept
->
ice::ncount
63
{
64
return
ice::ncount
{ value };
65
}
66
67
static
constexpr
ice::meminfo
Test_Meminfo
=
ice::meminfo_of<ice::ncount>
;
68
// For x64 platforms, size of size_t, for x32 platforms 2x32
69
static_assert
(
Test_Meminfo
.size == 8_B);
70
71
}
// namespace ice
mem.hxx
ice::detail::nvalue_min_value
consteval auto nvalue_min_value() noexcept -> ice::detail::nvalue_base_utype
Definition
nvalue.hxx:63
ice::detail::nvalue_max_value
consteval auto nvalue_max_value() noexcept -> ice::detail::nvalue_base_utype
Definition
nvalue.hxx:68
ice
SPDX-License-Identifier: MIT.
Definition
array.hxx:12
ice::ncount_min
static constexpr ice::ncount ncount_min
Definition
ncount.hxx:59
ice::ncount_max
static constexpr ice::ncount ncount_max
Definition
ncount.hxx:58
ice::Test_Meminfo
static constexpr ice::meminfo Test_Meminfo
Definition
ncount.hxx:67
ice::meminfo_of
constexpr ice::meminfo meminfo_of
Definition
mem_info.hxx:18
ice::ncount_none
static constexpr ice::ncount_invalid_t ncount_none
Definition
ncount.hxx:60
nvalue.hxx
ice::meminfo
Definition
mem_size_types.hxx:59
ice::ncount_invalid_t
Definition
ncount.hxx:34
ice::ncount
Definition
ncount.hxx:14
ice::ncount::operator==
constexpr bool operator==(this ncount self, ncount_invalid_t) noexcept
Definition
ncount.hxx:53
ice::ncount::base_signed_type
ice::detail::nvalue_base_stype base_signed_type
Definition
nvalue.hxx:76
ice::ncount::bytes
constexpr auto bytes(this ncount self) noexcept -> ice::usize
Definition
ncount.hxx:36
ice::ncount::usize
constexpr operator ice::usize(this ncount self) noexcept
Definition
ncount.hxx:31
ice::ncount::ncount
constexpr ncount() noexcept=default
ice::ncount::base_type
ice::detail::nvalue_base_utype base_type
Definition
nvalue.hxx:75
ice::nvalue
Definition
nvalue.hxx:74
ice::nvalue::base_signed_type
ice::detail::nvalue_base_stype base_signed_type
Definition
nvalue.hxx:76
ice::nvalue::base_type
ice::detail::nvalue_base_utype base_type
Definition
nvalue.hxx:75
ice::usize
Represents a unsigned size value on the given platform.
Definition
mem_size_types.hxx:26
ice::usize::base_type
std::size_t base_type
Definition
mem_size_types.hxx:28
Generated by
1.18.0