Browse Source

registry: avoid casting return types directly to better support empty storage

Michele Caini 2 years ago
parent
commit
6e2d871844
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/entt/entity/registry.hpp

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

@@ -1008,7 +1008,7 @@ public:
     template<typename... Type>
     template<typename... Type>
     [[nodiscard]] decltype(auto) get([[maybe_unused]] const entity_type entt) {
     [[nodiscard]] decltype(auto) get([[maybe_unused]] const entity_type entt) {
         if constexpr(sizeof...(Type) == 1u) {
         if constexpr(sizeof...(Type) == 1u) {
-            return (const_cast<Type &>(std::as_const(*this).template get<Type>(entt)), ...);
+            return (static_cast<storage_for_type<Type> &>(assure<std::remove_const_t<Type>>()).get(entt), ...);
         } else {
         } else {
             return std::forward_as_tuple(get<Type>(entt)...);
             return std::forward_as_tuple(get<Type>(entt)...);
         }
         }