Просмотр исходного кода

registry: ::storage<T> doesn't accept const types anymore

Michele Caini 3 лет назад
Родитель
Сommit
affd2a3b91
2 измененных файлов с 4 добавлено и 10 удалено
  1. 4 8
      src/entt/entity/registry.hpp
  2. 0 2
      test/entt/entity/registry.cpp

+ 4 - 8
src/entt/entity/registry.hpp

@@ -426,12 +426,8 @@ public:
      * @return The storage for the given component type.
      */
     template<typename Component>
-    decltype(auto) storage(const id_type id = type_hash<std::remove_const_t<Component>>::value()) {
-        if constexpr(std::is_const_v<Component>) {
-            return std::as_const(*this).template storage<std::remove_const_t<Component>>(id);
-        } else {
-            return assure<Component>(id);
-        }
+    decltype(auto) storage(const id_type id = type_hash<Component>::value()) {
+        return assure<Component>(id);
     }
 
     /**
@@ -446,8 +442,8 @@ public:
      * @return The storage for the given component type.
      */
     template<typename Component>
-    decltype(auto) storage(const id_type id = type_hash<std::remove_const_t<Component>>::value()) const {
-        return assure<std::remove_const_t<Component>>(id);
+    decltype(auto) storage(const id_type id = type_hash<Component>::value()) const {
+        return assure<Component>(id);
     }
 
     /**

+ 0 - 2
test/entt/entity/registry.cpp

@@ -1944,9 +1944,7 @@ TEST(Registry, RuntimePools) {
     const auto entity = registry.create();
 
     static_assert(std::is_same_v<decltype(registry.storage<empty_type>()), typename entt::storage_traits<entt::entity, empty_type>::storage_type &>);
-    static_assert(std::is_same_v<decltype(registry.storage<const empty_type>()), const typename entt::storage_traits<entt::entity, empty_type>::storage_type &>);
     static_assert(std::is_same_v<decltype(std::as_const(registry).storage<empty_type>()), const typename entt::storage_traits<entt::entity, empty_type>::storage_type &>);
-    static_assert(std::is_same_v<decltype(std::as_const(registry).storage<const empty_type>()), const typename entt::storage_traits<entt::entity, empty_type>::storage_type &>);
 
     static_assert(std::is_same_v<decltype(registry.storage("other"_hs)->second), typename entt::storage_traits<entt::entity, empty_type>::storage_type::base_type &>);
     static_assert(std::is_same_v<decltype(std::as_const(registry).storage("other"_hs)->second), const typename entt::storage_traits<entt::entity, empty_type>::storage_type::base_type &>);