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_arithmetic.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/mem_info.hxx
>
6
#include <type_traits>
7
8
namespace
ice
9
{
10
12
inline
auto
ptr_adv
(
void
* pointer,
ice::usize
offset,
ice::ualign
align)
noexcept
->
void
*;
13
15
inline
auto
ptr_adv
(
void
const
* pointer,
ice::usize
offset,
ice::ualign
align)
noexcept
->
void
const
*;
16
18
inline
auto
ptr_add
(
void
* pointer,
ice::usize
offset)
noexcept
->
void
*;
19
21
inline
auto
ptr_add
(
void
const
* pointer,
ice::usize
offset)
noexcept
->
void
const
*;
22
23
25
inline
auto
ptr_sub
(
void
* pointer,
ice::usize
offset)
noexcept
->
void
*;
26
28
inline
auto
ptr_sub
(
void
const
* pointer,
ice::usize
offset)
noexcept
->
void
const
*;
29
31
inline
auto
ptr_distance
(
void
const
* ptr_from,
void
const
* ptr_to)
noexcept
->
ice::usize
;
32
33
34
inline
auto
ptr_add
(
void
* ptr,
ice::usize
offset)
noexcept
->
void
*
35
{
36
return
reinterpret_cast<
char
*
>
(ptr) + offset.value;
37
}
38
39
inline
auto
ptr_add
(
void
const
* ptr,
ice::usize
offset)
noexcept
->
void
const
*
40
{
41
return
reinterpret_cast<
char
const*
>
(ptr) + offset.value;
42
}
43
44
inline
auto
ptr_sub
(
void
* ptr,
ice::usize
offset)
noexcept
->
void
*
45
{
46
return
reinterpret_cast<
char
*
>
(ptr) - offset.value;
47
}
48
49
inline
auto
ptr_sub
(
void
const
* ptr,
ice::usize
offset)
noexcept
->
void
const
*
50
{
51
return
reinterpret_cast<
char
const*
>
(ptr) - offset.value;
52
}
53
54
inline
auto
ptr_distance
(
void
const
* ptr_from,
void
const
* ptr_to)
noexcept
->
ice::usize
55
{
56
ICE_ASSERT_CORE
(ptr_from <= ptr_to);
57
return
{
ice::usize::base_type
(
reinterpret_cast<
char
const*
>
(ptr_to) -
reinterpret_cast<
char
const*
>
(ptr_from)) };
58
}
59
60
inline
auto
ptr_offset
(
void
const
* ptr_from,
void
const
* ptr_to)
noexcept
->
ice::isize
61
{
62
return
{
ice::isize::base_type
(
reinterpret_cast<
char
const*
>
(ptr_to) -
reinterpret_cast<
char
const*
>
(ptr_from)) };
63
}
64
65
}
// namespace ice
ICE_ASSERT_CORE
#define ICE_ASSERT_CORE(expression)
Definition
assert_core.hxx:43
mem_info.hxx
ice
SPDX-License-Identifier: MIT.
Definition
array.hxx:12
ice::ptr_adv
auto ptr_adv(void *pointer, ice::usize offset, ice::ualign align) noexcept -> void *
ice::ptr_sub
auto ptr_sub(void *pointer, ice::usize offset) noexcept -> void *
Definition
mem_arithmetic.hxx:44
ice::ptr_add
auto ptr_add(void *pointer, ice::usize offset) noexcept -> void *
Definition
mem_arithmetic.hxx:34
ice::ptr_distance
auto ptr_distance(void const *ptr_from, void const *ptr_to) noexcept -> ice::usize
Definition
mem_arithmetic.hxx:54
ice::ualign
ualign
Definition
mem_size_types.hxx:39
ice::ptr_offset
auto ptr_offset(void const *ptr_from, void const *ptr_to) noexcept -> ice::isize
Definition
mem_arithmetic.hxx:60
ice::isize
Represents a signed size value on the given platform.
Definition
mem_size_types.hxx:14
ice::isize::base_type
std::conditional_t< ice::build::is_x64, ice::i64, ice::i32 > base_type
Definition
mem_size_types.hxx:16
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