|
- #pragma once
-
- #include <ecs/config.h>
-
- #include <ecs/core/mp/core/copy_qualifiers.h>
-
- beg_namespace_ecs_core_utils
- {
-
- template <typename T, typename T_storage>
- inline constexpr decltype(auto) storage_cast(T_storage* storage) noexcept
- {
- static_assert(
- sizeof(T_storage) >= sizeof(T),
- "`T_storage` is not big enough for `T`.");
-
- static_assert(
- alignof(T_storage) >= alignof(T),
- "`T_storage` is not properly aligned for `T`.");
-
- assert(storage != nullptr);
-
- using return_type = mp::copy_cv_qualifiers<T, T_storage>;
- return reinterpret_cast<return_type*>(storage);
- }
-
-
- }
- end_namespace_ecs_core_utils
|