Browse Source

fixed constness

Michele Caini 7 years ago
parent
commit
380745a814
2 changed files with 4 additions and 4 deletions
  1. 3 2
      src/entt/entity/actor.hpp
  2. 1 2
      src/entt/entity/prototype.hpp

+ 3 - 2
src/entt/entity/actor.hpp

@@ -4,6 +4,7 @@
 
 #include <cassert>
 #include <utility>
+#include <type_traits>
 #include "../config/config.h"
 #include "registry.hpp"
 #include "entity.hpp"
@@ -126,7 +127,7 @@ struct actor {
      */
     template<typename... Component>
     decltype(auto) get() const ENTT_NOEXCEPT {
-        return reg->template get<Component...>(entt);
+        return std::as_const(*reg).template get<Component...>(entt);
     }
 
     /**
@@ -146,7 +147,7 @@ struct actor {
      */
     template<typename... Component>
     auto get_if() const ENTT_NOEXCEPT {
-        return reg->template get_if<Component...>(entt);
+        return std::as_const(*reg).template get_if<Component...>(entt);
     }
 
     /**

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

@@ -184,8 +184,7 @@ public:
     template<typename... Component>
     decltype(auto) get() const ENTT_NOEXCEPT {
         if constexpr(sizeof...(Component) == 1) {
-            const auto &component = reg->template get<component_wrapper<Component...>>(entity).component;
-            return component;
+            return (std::as_const(*reg).template get<component_wrapper<Component...>>(entity).component);
         } else {
             return std::tuple<const Component &...>{get<Component>()...};
         }