acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
pointer_container.h
1
//
2
// Created by camilo on 2026-04-23 <3ThomasBorregaardSørensen!! and Mummi!!
3
//
4
#pragma once
5
6
7
8
// 1. Define a helper type trait
9
template
<
typename
T,
template
<
typename
...>
class
Template>
10
struct
is_specialization_of_t
: ::false_type
11
{
12
};
13
14
template
<
template
<
typename
...>
class
Template,
typename
... Args>
15
struct
is_specialization_of_t
<Template<Args...>, Template> : ::true_type
16
{
17
};
18
19
// 2. Wrap the trait in a concept
20
template
<
typename
T,
template
<
typename
...>
class
Template>
21
concept
is_specialization_of
=
is_specialization_of_t<std::decay_t<T>
, Template>
::payload
;
22
23
// Example Usage:
24
//static_assert(is_specialization_of<array_base<::i32>, array_base>); // Passes
25
//static_assert(!is_specialization_of<::i32, array_base); // Fails
26
28
//template<typename T, template<typename...> class Template>
29
//struct is_instantiation_of : std::false_type
30
//{
31
//};
32
//
33
//
34
//template<template<typename...> class Template, typename... Args>
35
//struct is_instantiation_of<Template<Args...>, Template> : std::true_type
36
//{
37
//};
38
//
39
//
41
//template<typename T, template<typename...> class Template>
42
//concept InstantiationOf = is_instantiation_of<T, Template>::value;
43
44
46
//void process_vector(InstantiationOf<std::vector> auto const &vec)
47
//{
48
// // This function only accepts std::vector instantiations
49
//}
50
51
52
template
<
typename
POINTER_CONTAINER >
53
concept
prototype_pointer_container
=
is_specialization_of<typename POINTER_CONTAINER::BASE_PAYLOAD, ::pointer>
;
54
55
56
template
<prototype_po
int
er_container POINTER_CONTAINER>
57
void
defer_destroy_and_release_each_pointer_payload_in_container(POINTER_CONTAINER &container)
58
{
59
60
for
(
auto
&p: container.payloads())
61
{
62
63
p.defer_destroy_and_release();
64
65
}
66
67
}
68
69
70
template
<prototype_po
int
er_container POINTER_CONTAINER>
71
void
defer_destroy_and_release_each_payload_pointer_in_container_and_then_clear_it(POINTER_CONTAINER &container)
72
{
73
74
defer_destroy_and_release_each_pointer_payload_in_container(container);
75
76
container.clear();
77
78
}
79
80
81
template
<
typename
TYPE>
82
class
ø
83
{
84
public
:
85
86
};
87
88
89
template
<
typename
TYPE1,
typename
TYPE2,
class
PAIR = pair < TYPE1, ::po
int
er < TYPE2 > >, enum_allocate t_eallocate = e_allocate_normal >
90
using
map_to_pointer_base = ::ø < pair_map_base < PAIR, t_eallocate > >;
91
92
93
template
<
typename
TYPE1,
typename
TYPE2,
class
PAIR = pair < TYPE1, TYPE2 >, enum_allocate t_eallocate = e_allocate_normal >
94
using
map_to_pointer = map_particle < map_to_pointer_base < TYPE1, TYPE2, PAIR, t_eallocate > >;
95
96
97
98
99
100
101
template
<prototype_po
int
er_container POINTER_CONTAINER>
102
class
ø
<POINTER_CONTAINER> :
103
public
POINTER_CONTAINER
104
{
105
public
:
106
107
108
using
BASE_CONTAINER = POINTER_CONTAINER;
109
110
111
using
BASE_CONTAINER::BASE_CONTAINER;
112
using
BASE_CONTAINER::operator=;
113
114
115
void
_defer_destroy_and_release() { ::defer_destroy_and_release_each_pointer_payload_in_container(*
this
); }
116
117
118
void
defer_destroy_and_release()
119
{
120
121
::defer_destroy_and_release_each_payload_pointer_in_container_and_then_clear_it(*
this
);
122
}
123
};
124
125
ø
Definition
pointer_container.h:83
payload
Definition
payload.h:54
is_specialization_of
Definition
pointer_container.h:21
prototype_pointer_container
Definition
pointer_container.h:53
is_specialization_of_t
Definition
pointer_container.h:11
prototype
collection
pointer_container.h
Generated by
1.17.0