IceShard
1
A personal game engine project, with development focused on 2D/2.5D games.
Toggle main menu visibility
Loading...
Searching...
No Matches
core
public
ice
base.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/types.hxx
>
6
#include <
ice/types_extended.hxx
>
7
#include <
ice/constants.hxx
>
8
#include <
ice/workarounds.hxx
>
9
#include <
ice/build/build.hxx
>
10
#include <
ice/assert_core.hxx
>
11
#include <
ice/utility.hxx
>
12
#include <
ice/hash.hxx
>
13
14
#include <
ice/concept/enum_bools.hxx
>
15
#include <
ice/concept/enum_flags.hxx
>
16
#include <
ice/concept/strong_type_value.hxx
>
17
18
#include <
ice/error.hxx
>
19
#include <
ice/error_codes.hxx
>
20
21
#include <algorithm>
22
#include <cstring>
23
#include <utility>
24
#include <bit>
25
26
namespace
ice
27
{
28
29
using
std::min;
30
using
std::max;
31
using
std::abs;
32
33
using
std::swap;
34
using
std::move;
35
using
std::forward;
36
using
std::exchange;
37
using
std::memcpy;
38
using
std::memset;
39
using
std::addressof;
40
using
std::bit_cast;
41
42
template
<
typename
T, ice::u32 Size>
43
constexpr
auto
count
(T
const
(&)[Size])
noexcept
->
ice::u32
44
{
45
return
Size;
46
}
47
48
template
<
typename
T,
typename
U = T>
requires
(std::convertible_to<U, T>)
49
constexpr
auto
value_or_default
(T value, U default_value)
noexcept
-> T =
delete
;
50
51
template
<
typename
T,
typename
U = T>
requires
(std::convertible_to<U*, T*>)
52
constexpr
auto
value_or_default
(T* value, U* default_value)
noexcept
-> T*
53
{
54
return
value !=
nullptr
? value : default_value;
55
}
56
57
template
<
typename
T,
typename
U = T>
requires
(std::convertible_to<U, T> && std::is_arithmetic_v<T>)
58
constexpr
auto
value_or_default
(T value, U&& default_value)
noexcept
-> T
59
{
60
return
value !=
nullptr
? value :
static_cast<
T
>
(ice::forward<U>(default_value));
61
}
62
63
template
<
typename
T>
64
using
clear_type_t
= std::remove_pointer_t<std::remove_reference_t<std::remove_cv_t<T>>>;
65
66
template
<
typename
T>
67
using
clean_type
=
clear_type_t<T>
;
68
69
template
<
typename
T>
70
constexpr
auto
to_const
(T* value)
noexcept
-> T
const
*
71
{
72
return
const_cast<
T const*
>
(value);
73
}
74
75
template
<
typename
T,
typename
=
void
>
76
constexpr
bool
is_type_complete
=
false
;
77
78
template
<
typename
T>
79
constexpr
bool
is_type_complete
<T, std::void_t<
decltype
(
sizeof
(T))>> =
true
;
80
81
82
template
<
typename
Member>
83
struct
member_info
84
{
85
static
constexpr
ice::u8
member_type
= 0;
86
};
87
88
template
<
typename
Class,
typename
Ret,
typename
... Args>
89
struct
member_info
<Ret(Class::*)(Args...)>
90
{
91
static
constexpr
ice::u8
member_type
= 1;
92
using
class_type
= Class;
93
using
result_type
= Ret;
94
95
static
constexpr
ice::u8
argument_count
=
sizeof
...(Args);
96
using
argument_types
= std::tuple<Args...>;
97
};
98
99
template
<
typename
Class,
typename
Ret,
typename
... Args>
100
struct
member_info
<Ret(Class::*)(Args...) noexcept>
101
{
102
static
constexpr
ice::u8
member_type
= 1;
103
using
class_type
= Class;
104
using
result_type
= Ret;
105
106
static
constexpr
ice::u8
argument_count
=
sizeof
...(Args);
107
using
argument_types
= std::tuple<Args...>;
108
};
109
110
template
<
typename
Class,
typename
Value>
111
struct
member_info
<Value Class::*>
112
{
113
static
constexpr
ice::u8
member_type
= 2;
114
using
class_type
= Class;
115
using
result_type
= Value;
116
};
117
118
template
<
typename
Member>
119
using
member_class_type_t
=
typename
member_info<Member>::class_type
;
120
121
template
<
typename
Member>
122
using
member_result_type_t
=
typename
member_info<Member>::result_type
;
123
124
template
<
typename
Member, ice::u64 Idx>
125
using
member_arg_type_t
= std::tuple_element_t<Idx, typename member_info<Member>::argument_types>;
126
127
template
<
typename
Member>
128
constexpr
bool
is_method_member_v
=
member_info<Member>::member_type
== 1;
129
130
template
<
typename
Member>
131
constexpr
bool
is_field_member_v
=
member_info<Member>::member_type
== 2;
132
133
}
// namespace ice
assert_core.hxx
build.hxx
constants.hxx
enum_bools.hxx
enum_flags.hxx
error.hxx
error_codes.hxx
hash.hxx
ice
SPDX-License-Identifier: MIT.
Definition
array.hxx:12
ice::member_result_type_t
typename member_info< Member >::result_type member_result_type_t
Definition
base.hxx:122
ice::clear_type_t
std::remove_pointer_t< std::remove_reference_t< std::remove_cv_t< T > > > clear_type_t
Definition
base.hxx:64
ice::is_type_complete
constexpr bool is_type_complete
Definition
base.hxx:76
ice::member_class_type_t
typename member_info< Member >::class_type member_class_type_t
Definition
base.hxx:119
ice::is_method_member_v
constexpr bool is_method_member_v
Definition
base.hxx:128
ice::value_or_default
constexpr auto value_or_default(T value, U default_value) noexcept -> T=delete
ice::to_const
constexpr auto to_const(T *value) noexcept -> T const *
Definition
base.hxx:70
ice::count
constexpr auto count(T const (&)[Size]) noexcept -> ice::u32
Definition
base.hxx:43
ice::u32
std::uint32_t u32
Definition
types.hxx:26
ice::member_arg_type_t
std::tuple_element_t< Idx, typename member_info< Member >::argument_types > member_arg_type_t
Definition
base.hxx:125
ice::clean_type
clear_type_t< T > clean_type
Definition
base.hxx:67
ice::is_field_member_v
constexpr bool is_field_member_v
Definition
base.hxx:131
ice::u8
std::uint8_t u8
Definition
types.hxx:24
strong_type_value.hxx
ice::member_info< Ret(Class::*)(Args...) noexcept >::class_type
Class class_type
Definition
base.hxx:103
ice::member_info< Ret(Class::*)(Args...) noexcept >::argument_count
static constexpr ice::u8 argument_count
Definition
base.hxx:106
ice::member_info< Ret(Class::*)(Args...) noexcept >::argument_types
std::tuple< Args... > argument_types
Definition
base.hxx:107
ice::member_info< Ret(Class::*)(Args...) noexcept >::member_type
static constexpr ice::u8 member_type
Definition
base.hxx:102
ice::member_info< Ret(Class::*)(Args...) noexcept >::result_type
Ret result_type
Definition
base.hxx:104
ice::member_info< Ret(Class::*)(Args...)>::argument_count
static constexpr ice::u8 argument_count
Definition
base.hxx:95
ice::member_info< Ret(Class::*)(Args...)>::result_type
Ret result_type
Definition
base.hxx:93
ice::member_info< Ret(Class::*)(Args...)>::class_type
Class class_type
Definition
base.hxx:92
ice::member_info< Ret(Class::*)(Args...)>::member_type
static constexpr ice::u8 member_type
Definition
base.hxx:91
ice::member_info< Ret(Class::*)(Args...)>::argument_types
std::tuple< Args... > argument_types
Definition
base.hxx:96
ice::member_info< Value Class::* >::class_type
Class class_type
Definition
base.hxx:114
ice::member_info< Value Class::* >::result_type
Value result_type
Definition
base.hxx:115
ice::member_info< Value Class::* >::member_type
static constexpr ice::u8 member_type
Definition
base.hxx:113
ice::member_info
Definition
base.hxx:84
ice::member_info::member_type
static constexpr ice::u8 member_type
Definition
base.hxx:85
types.hxx
types_extended.hxx
utility.hxx
workarounds.hxx
Generated by
1.18.0