storage: removed const T specialization for storage_traits

This commit is contained in:
Michele Caini
2020-11-08 01:06:06 +01:00
parent ec56651959
commit 0038728be3
4 changed files with 6 additions and 13 deletions

View File

@@ -69,7 +69,7 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>> final {
friend class basic_registry<Entity>;
template<typename Component>
using storage_type = typename storage_traits<Entity, Component>::storage_type;
using storage_type = constness_as_t<typename storage_traits<Entity, std::remove_const_t<Component>>::storage_type, Component>;
class iterable_group final {
friend class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>>;
@@ -574,7 +574,7 @@ class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...> final
friend class basic_registry<Entity>;
template<typename Component>
using storage_type = typename storage_traits<Entity, Component>::storage_type;
using storage_type = constness_as_t<typename storage_traits<Entity, std::remove_const_t<Component>>::storage_type, Component>;
class iterable_group final {
friend class basic_group<Entity, exclude_t<Exclude...>, get_t<Get...>, Owned...>;

View File

@@ -14,6 +14,7 @@
#include "../core/algorithm.hpp"
#include "../core/fwd.hpp"
#include "../core/type_info.hpp"
#include "../core/type_traits.hpp"
#include "entity.hpp"
#include "fwd.hpp"
#include "group.hpp"
@@ -42,7 +43,7 @@ class basic_registry {
using traits_type = entt_traits<Entity>;
template<typename Component>
using storage_type = typename storage_traits<Entity, Component>::storage_type;
using storage_type = constness_as_t<typename storage_traits<Entity, std::remove_const_t<Component>>::storage_type, Component>;
struct pool_data {
type_info info{};

View File

@@ -806,14 +806,6 @@ struct storage_traits {
};
/*! @copydoc storage_traits */
template<typename Entity, typename Type>
struct storage_traits<Entity, const Type> {
/*! @brief Resulting type after component-to-storage conversion. */
using storage_type = std::add_const_t<typename storage_traits<Entity, std::remove_const_t<Type>>::storage_type>;
};
/**
* @brief Gets the element associated with an entity from a storage, if any.
* @tparam Type Storage type.

View File

@@ -69,7 +69,7 @@ class basic_view<Entity, exclude_t<Exclude...>, Component...> final {
friend class basic_registry<Entity>;
template<typename Comp>
using storage_type = typename storage_traits<Entity, Comp>::storage_type;
using storage_type = constness_as_t<typename storage_traits<Entity, std::remove_const_t<Comp>>::storage_type, Comp>;
using unchecked_type = std::array<const basic_sparse_set<Entity> *, (sizeof...(Component) - 1)>;
@@ -558,7 +558,7 @@ class basic_view<Entity, exclude_t<>, Component> final {
/*! @brief A registry is allowed to create views. */
friend class basic_registry<Entity>;
using storage_type = typename storage_traits<Entity, Component>::storage_type;
using storage_type = constness_as_t<typename storage_traits<Entity, std::remove_const_t<Component>>::storage_type, Component>;
class iterable_view {
friend class basic_view<Entity, exclude_t<>, Component>;