#include #include #include #include struct entity_id { using entity_type = typename entt::entt_traits::entity_type; entity_id(entity_type value = entt::null) : entt{value} {} entity_id(const entity_id &other) : entt{other.entt} {} operator entity_type() const { return entt; } private: entity_type entt; }; template<> struct entt::entt_traits: entt::entt_traits {}; TEST(Example, CustomIdentifier) { entt::basic_registry registry{}; entity_id entity{}; ASSERT_FALSE(registry.valid(entity)); ASSERT_TRUE(entity == entt::null); entity = registry.create(); ASSERT_TRUE(registry.valid(entity)); ASSERT_TRUE(entity != entt::null); ASSERT_FALSE((registry.has(entity))); ASSERT_EQ(registry.try_get(entity), nullptr); registry.emplace(entity, 42); ASSERT_TRUE((registry.any(entity))); ASSERT_EQ(registry.get(entity), 42); registry.destroy(entity); ASSERT_FALSE(registry.valid(entity)); ASSERT_TRUE(entity != entt::null); entity = registry.create(); ASSERT_TRUE(registry.valid(entity)); ASSERT_TRUE(entity != entt::null); }