IceShard
1
A personal game engine project, with development focused on 2D/2.5D games.
Toggle main menu visibility
Loading...
Searching...
No Matches
memsys
public
ice
mem_info.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/mem_align.hxx
>
6
#include <
ice/mem_size_types.hxx
>
7
8
namespace
ice
9
{
10
11
template
<
typename
T>
12
constexpr
ice::usize
size_of
= {
sizeof
(T) };
13
14
template
<
typename
T>
15
constexpr
ice::ualign
align_of
=
static_cast<
ice::ualign
>
(
alignof
(T));
16
17
template
<
typename
T>
18
constexpr
ice::meminfo
meminfo_of
= {
ice::size_of<T>
,
ice::align_of<T>
};
19
21
constexpr
auto
operator*
(
ice::meminfo
info
,
ice::u64
count
)
noexcept
->
ice::meminfo
22
{
23
return
ice::meminfo
{ .size =
ice::usize
{
info
.size.value *
count
}, .alignment =
info
.alignment };
24
}
25
36
constexpr
auto
operator+=
(
ice::meminfo
& left,
ice::meminfo
right)
noexcept
->
ice::usize
37
{
38
// Align first
39
ice::AlignResult
const
res =
ice::align_to
(left.size, right.alignment);
40
left.size = res.
value
;
41
42
ice::usize
const
result = left.size;
43
// The following line is commented out on purpose.
44
// We need to keep the original alignment so any allocation made
45
// will mimic all the added meminfo values and respect their offsets.
46
// left.alignment = right.alignment; // DON'T SET THIS
47
left.size += right.size;
48
return
result;
49
}
50
51
}
// namespace ice
mem_align.hxx
mem_size_types.hxx
ice::info
Definition
info.hxx:8
ice
SPDX-License-Identifier: MIT.
Definition
array.hxx:12
ice::size_of
constexpr ice::usize size_of
Definition
mem_info.hxx:12
ice::operator*
constexpr auto operator*(T left, T right) noexcept -> T
Definition
strong_type_integral.hxx:96
ice::operator+=
constexpr auto operator+=(T &left, T right) noexcept -> T &
Definition
strong_type_integral.hxx:120
ice::u64
std::uint64_t u64
Definition
types.hxx:27
ice::align_of
constexpr ice::ualign align_of
Definition
mem_info.hxx:15
ice::align_to
constexpr auto align_to(T value, ice::ualign alignment) noexcept -> ice::AlignResult< T >
Definition
mem_align.hxx:41
ice::count
constexpr auto count(T const (&)[Size]) noexcept -> ice::u32
Definition
base.hxx:43
ice::meminfo_of
constexpr ice::meminfo meminfo_of
Definition
mem_info.hxx:18
ice::ualign
ualign
Definition
mem_size_types.hxx:39
ice::AlignResult
Definition
mem_align.hxx:13
ice::AlignResult::value
T value
Definition
mem_align.hxx:14
ice::meminfo
Definition
mem_size_types.hxx:59
ice::usize
Represents a unsigned size value on the given platform.
Definition
mem_size_types.hxx:26
Generated by
1.18.0