14inline void ecs_ctor_illegal(
void *, int32_t,
const ecs_type_info_t *ti) {
15 ecs_abort(ECS_INVALID_OPERATION,
"invalid constructor for %s", ti->
name);
18inline void ecs_dtor_illegal(
void *, int32_t,
const ecs_type_info_t *ti) {
19 ecs_abort(ECS_INVALID_OPERATION,
"invalid destructor for %s", ti->
name);
22inline void ecs_copy_illegal(
25 ecs_abort(ECS_INVALID_OPERATION,
"invalid copy assignment for %s", ti->
name);
28inline void ecs_move_illegal(
void *,
void *, int32_t,
const ecs_type_info_t *ti) {
29 ecs_abort(ECS_INVALID_OPERATION,
"invalid move assignment for %s", ti->
name);
32inline void ecs_copy_ctor_illegal(
35 ecs_abort(ECS_INVALID_OPERATION,
"invalid copy construct for %s", ti->
name);
38inline void ecs_move_ctor_illegal(
41 ecs_abort(ECS_INVALID_OPERATION,
"invalid move construct for %s", ti->
name);
50 ECS_INTERNAL_ERROR, NULL);
51 T *arr =
static_cast<T*
>(ptr);
52 for (
int i = 0; i < count; i ++) {
53 FLECS_PLACEMENT_NEW(&arr[i], T);
61 ECS_INTERNAL_ERROR, NULL);
62 T *arr =
static_cast<T*
>(ptr);
63 for (
int i = 0; i < count; i ++) {
70void copy_impl(
void *dst_ptr,
const void *src_ptr, int32_t count,
74 ECS_INTERNAL_ERROR, NULL);
75 T *dst_arr =
static_cast<T*
>(dst_ptr);
76 const T *src_arr =
static_cast<const T*
>(src_ptr);
77 for (
int i = 0; i < count; i ++) {
78 dst_arr[i] = src_arr[i];
84void move_impl(
void *dst_ptr,
void *src_ptr, int32_t count,
88 ECS_INTERNAL_ERROR, NULL);
89 T *dst_arr =
static_cast<T*
>(dst_ptr);
90 T *src_arr =
static_cast<T*
>(src_ptr);
91 for (
int i = 0; i < count; i ++) {
92 dst_arr[i] = FLECS_MOV(src_arr[i]);
98void copy_ctor_impl(
void *dst_ptr,
const void *src_ptr, int32_t count,
102 ECS_INTERNAL_ERROR, NULL);
103 T *dst_arr =
static_cast<T*
>(dst_ptr);
104 const T *src_arr =
static_cast<const T*
>(src_ptr);
105 for (
int i = 0; i < count; i ++) {
106 FLECS_PLACEMENT_NEW(&dst_arr[i], T(src_arr[i]));
112void move_ctor_impl(
void *dst_ptr,
void *src_ptr, int32_t count,
116 ECS_INTERNAL_ERROR, NULL);
117 T *dst_arr =
static_cast<T*
>(dst_ptr);
118 T *src_arr =
static_cast<T*
>(src_ptr);
119 for (
int i = 0; i < count; i ++) {
120 FLECS_PLACEMENT_NEW(&dst_arr[i], T(FLECS_MOV(src_arr[i])));
127void ctor_move_dtor_impl(
void *dst_ptr,
void *src_ptr, int32_t count,
131 ECS_INTERNAL_ERROR, NULL);
132 T *dst_arr =
static_cast<T*
>(dst_ptr);
133 T *src_arr =
static_cast<T*
>(src_ptr);
134 for (
int i = 0; i < count; i ++) {
135 FLECS_PLACEMENT_NEW(&dst_arr[i], T(FLECS_MOV(src_arr[i])));
142template <
typename T, if_not_t<
143 std::is_trivially_move_assignable<T>::value > = 0>
144void move_dtor_impl(
void *dst_ptr,
void *src_ptr, int32_t count,
148 ECS_INTERNAL_ERROR, NULL);
149 T *dst_arr =
static_cast<T*
>(dst_ptr);
150 T *src_arr =
static_cast<T*
>(src_ptr);
151 for (
int i = 0; i < count; i ++) {
153 dst_arr[i] = FLECS_MOV(src_arr[i]);
162template <
typename T, if_t<
163 std::is_trivially_move_assignable<T>::value > = 0>
164void move_dtor_impl(
void *dst_ptr,
void *src_ptr, int32_t count,
168 ECS_INTERNAL_ERROR, NULL);
169 T *dst_arr =
static_cast<T*
>(dst_ptr);
170 T *src_arr =
static_cast<T*
>(src_ptr);
171 for (
int i = 0; i < count; i ++) {
175 dst_arr[i] = FLECS_MOV(src_arr[i]);
187 static constexpr bool value =
188 std::is_default_constructible<actual_type_t<T>>::value;
195template <typename T, if_t< std::is_trivially_constructible<T>::value > = 0>
201template <
typename T, if_t<
202 ! std::is_default_constructible<T>::value > = 0>
204 return ecs_ctor_illegal;
208template <
typename T, if_t<
209 ! std::is_trivially_constructible<T>::value &&
210 std::is_default_constructible<T>::value > = 0>
216template <typename T, if_t< std::is_trivially_destructible<T>::value > = 0>
222template <
typename T, if_t<
223 std::is_destructible<T>::value &&
224 ! std::is_trivially_destructible<T>::value > = 0>
230template <typename T, if_not_t< std::is_destructible<T>::value > = 0>
232 flecs_static_assert(always_false<T>::value,
233 "component type must be destructible");
234 return ecs_dtor_illegal;
238template <typename T, if_t< std::is_trivially_copyable<T>::value > = 0>
244template <
typename T, if_t<
245 ! std::is_trivially_copyable<T>::value &&
246 ! std::is_copy_assignable<T>::value > = 0>
248 return ecs_copy_illegal;
252template <
typename T, if_t<
253 std::is_copy_assignable<T>::value &&
254 ! std::is_trivially_copyable<T>::value > = 0>
260template <typename T, if_t< std::is_trivially_move_assignable<T>::value > = 0>
266template <typename T, if_not_t< std::is_move_assignable<T>::value > = 0>
268 return ecs_move_illegal;
272template <
typename T, if_t<
273 std::is_move_assignable<T>::value &&
274 ! std::is_trivially_move_assignable<T>::value > = 0>
280template <
typename T, if_t<
281 std::is_trivially_copy_constructible<T>::value > = 0>
287template <typename T, if_t< ! std::is_copy_constructible<T>::value > = 0>
289 return ecs_copy_ctor_illegal;
293template <
typename T, if_t<
294 std::is_copy_constructible<T>::value &&
295 ! std::is_trivially_copy_constructible<T>::value > = 0>
297 return copy_ctor_impl<T>;
301template <
typename T, if_t<
302 std::is_trivially_move_constructible<T>::value > = 0>
308template <typename T, if_not_t< std::is_move_constructible<T>::value > = 0>
310 return ecs_move_ctor_illegal;
314template <
typename T, if_t<
315 std::is_move_constructible<T>::value &&
316 ! std::is_trivially_move_constructible<T>::value > = 0>
318 return move_ctor_impl<T>;
322template <
typename T, if_t<
323 std::is_trivially_move_constructible<T>::value &&
324 std::is_trivially_destructible<T>::value > = 0>
330template <
typename T, if_t<
331 ! std::is_move_constructible<T>::value ||
332 ! std::is_destructible<T>::value > = 0>
334 return ecs_move_ctor_illegal;
338template <
typename T, if_t<
339 !(std::is_trivially_move_constructible<T>::value &&
340 std::is_trivially_destructible<T>::value) &&
341 std::is_move_constructible<T>::value &&
342 std::is_destructible<T>::value > = 0>
344 return ctor_move_dtor_impl<T>;
348template <
typename T, if_t<
349 std::is_trivially_move_assignable<T>::value &&
350 std::is_trivially_destructible<T>::value > = 0>
356template <
typename T, if_t<
357 ! std::is_move_assignable<T>::value ||
358 ! std::is_destructible<T>::value > = 0>
360 return ecs_move_ctor_illegal;
364template <
typename T, if_t<
365 !(std::is_trivially_move_assignable<T>::value &&
366 std::is_trivially_destructible<T>::value) &&
367 std::is_move_assignable<T>::value &&
368 std::is_destructible<T>::value > = 0>
370 return move_dtor_impl<T>;
#define ecs_assert(condition, error_code,...)
Assert.
#define ecs_abort(error_code,...)
Abort.
void(* ecs_copy_t)(void *dst_ptr, const void *src_ptr, int32_t count, const ecs_type_info_t *type_info)
Copy is invoked when a component is copied into another component.
void(* ecs_move_t)(void *dst_ptr, void *src_ptr, int32_t count, const ecs_type_info_t *type_info)
Move is invoked when a component is moved to another component.
void(* ecs_xtor_t)(void *ptr, int32_t count, const ecs_type_info_t *type_info)
Constructor/destructor callback.
Type that contains component information (passed to ctors/dtors/...)
ecs_size_t size
Size of type.
const char * name
Type name.