Browse Source

registry: prepare to drop static storage within const assure

Michele Caini 3 năm trước cách đây
mục cha
commit
9a457c5aca
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      src/entt/entity/registry.hpp

+ 2 - 1
src/entt/entity/registry.hpp

@@ -1110,7 +1110,8 @@ public:
     template<typename... Type>
     template<typename... Type>
     [[nodiscard]] auto try_get([[maybe_unused]] const entity_type entt) {
     [[nodiscard]] auto try_get([[maybe_unused]] const entity_type entt) {
         if constexpr(sizeof...(Type) == 1) {
         if constexpr(sizeof...(Type) == 1) {
-            return (const_cast<Type *>(std::as_const(*this).template try_get<Type>(entt)), ...);
+            auto &cpool = assure<std::remove_const_t<Type>...>();
+            return (static_cast<Type *>(cpool.contains(entt) ? std::addressof(cpool.get(entt)) : nullptr), ...);
         } else {
         } else {
             return std::make_tuple(try_get<Type>(entt)...);
             return std::make_tuple(try_get<Type>(entt)...);
         }
         }