entity: make entt_traits sfinae-friendly and avoid using std::underlying_type_t to define the entity traits types
This commit is contained in:
@@ -18,10 +18,20 @@ namespace entt {
|
||||
* Primary template isn't defined on purpose. All the specializations give a
|
||||
* compile-time error unless the template parameter is an accepted entity type.
|
||||
*/
|
||||
template<typename>
|
||||
template<typename, typename = void>
|
||||
struct entt_traits;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Entity traits for enumeration types.
|
||||
* @tparam Type The type to check.
|
||||
*/
|
||||
template<typename Type>
|
||||
struct entt_traits<Type, std::enable_if_t<std::is_enum_v<Type>>>
|
||||
: entt_traits<std::underlying_type_t<Type>>
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Entity traits for a 16 bits entity identifier.
|
||||
*
|
||||
@@ -111,7 +121,7 @@ namespace internal {
|
||||
|
||||
class null {
|
||||
template<typename Entity>
|
||||
using traits_type = entt_traits<std::underlying_type_t<Entity>>;
|
||||
using traits_type = entt_traits<Entity>;
|
||||
|
||||
public:
|
||||
template<typename Entity>
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace entt {
|
||||
*/
|
||||
template<typename Entity>
|
||||
class basic_registry {
|
||||
using traits_type = entt_traits<std::underlying_type_t<Entity>>;
|
||||
using traits_type = entt_traits<Entity>;
|
||||
|
||||
template<typename Component>
|
||||
struct pool_handler final: storage<Entity, Component> {
|
||||
|
||||
@@ -32,7 +32,7 @@ class basic_snapshot {
|
||||
/*! @brief A registry is allowed to create snapshots. */
|
||||
friend class basic_registry<Entity>;
|
||||
|
||||
using traits_type = entt_traits<std::underlying_type_t<Entity>>;
|
||||
using traits_type = entt_traits<Entity>;
|
||||
|
||||
template<typename Component, typename Archive, typename It>
|
||||
void get(Archive &archive, std::size_t sz, It first, It last) const {
|
||||
@@ -164,7 +164,7 @@ class basic_snapshot_loader {
|
||||
/*! @brief A registry is allowed to create snapshot loaders. */
|
||||
friend class basic_registry<Entity>;
|
||||
|
||||
using traits_type = entt_traits<std::underlying_type_t<Entity>>;
|
||||
using traits_type = entt_traits<Entity>;
|
||||
|
||||
template<typename Type, typename Archive>
|
||||
void assign(Archive &archive) const {
|
||||
@@ -299,7 +299,7 @@ private:
|
||||
*/
|
||||
template<typename Entity>
|
||||
class basic_continuous_loader {
|
||||
using traits_type = entt_traits<std::underlying_type_t<Entity>>;
|
||||
using traits_type = entt_traits<Entity>;
|
||||
|
||||
void destroy(Entity entt) {
|
||||
const auto it = remloc.find(entt);
|
||||
|
||||
@@ -44,7 +44,7 @@ class sparse_set {
|
||||
static_assert(ENTT_PAGE_SIZE && ((ENTT_PAGE_SIZE & (ENTT_PAGE_SIZE - 1)) == 0), "ENTT_PAGE_SIZE must be a power of two");
|
||||
static constexpr auto entt_per_page = ENTT_PAGE_SIZE / sizeof(Entity);
|
||||
|
||||
using traits_type = entt_traits<std::underlying_type_t<Entity>>;
|
||||
using traits_type = entt_traits<Entity>;
|
||||
using page_type = std::unique_ptr<Entity[]>;
|
||||
|
||||
class sparse_set_iterator final {
|
||||
|
||||
@@ -49,7 +49,7 @@ class storage: public sparse_set<Entity> {
|
||||
static_assert(std::is_move_constructible_v<Type> && std::is_move_assignable_v<Type>, "The managed type must be at least move constructible and assignable");
|
||||
|
||||
using underlying_type = sparse_set<Entity>;
|
||||
using traits_type = entt_traits<std::underlying_type_t<Entity>>;
|
||||
using traits_type = entt_traits<Entity>;
|
||||
|
||||
template<bool Const>
|
||||
class storage_iterator final {
|
||||
@@ -478,7 +478,7 @@ private:
|
||||
/*! @copydoc storage */
|
||||
template<typename Entity, typename Type>
|
||||
class storage<Entity, Type, std::enable_if_t<ENTT_IS_EMPTY(Type)>>: public sparse_set<Entity> {
|
||||
using traits_type = entt_traits<std::underlying_type_t<Entity>>;
|
||||
using traits_type = entt_traits<Entity>;
|
||||
using underlying_type = sparse_set<Entity>;
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user