fixed constness

This commit is contained in:
Michele Caini
2018-10-30 14:25:03 +01:00
parent ce4e335412
commit 380745a814
2 changed files with 4 additions and 4 deletions

View File

@@ -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);
}
/**

View File

@@ -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>()...};
}