Browse Source

type_traits: removed internal is_empty[_v]

Michele Caini 4 years ago
parent
commit
a621b36389
3 changed files with 4 additions and 21 deletions
  1. 3 3
      src/entt/config/config.h
  2. 0 17
      src/entt/core/type_traits.hpp
  3. 1 1
      src/entt/entity/storage.hpp

+ 3 - 3
src/entt/config/config.h

@@ -60,12 +60,12 @@ static_assert(ENTT_PACKED_PAGE && ((ENTT_PACKED_PAGE & (ENTT_PACKED_PAGE - 1)) =
 #endif
 
 
-#ifndef ENTT_NO_ETO
+#ifdef ENTT_NO_ETO
 #   include <type_traits>
-#   define ENTT_IS_EMPTY(Type) std::is_empty<Type>
+#   define ENTT_IGNORE_IF_EMPTY std::false_type
 #else
 #   include <type_traits>
-#   define ENTT_IS_EMPTY(Type) std::false_type
+#   define ENTT_IGNORE_IF_EMPTY std::true_type
 #endif
 
 

+ 0 - 17
src/entt/core/type_traits.hpp

@@ -566,23 +566,6 @@ template<typename Type>
 inline constexpr auto is_complete_v = is_complete<Type>::value;
 
 
-/**
- * @brief Provides the member constant `value` to true if a given type is empty
- * and the empty type optimization is enabled, false otherwise.
- * @tparam Type Potential empty type.
- */
-template<typename Type, typename = void>
-struct is_empty: ENTT_IS_EMPTY(Type) {};
-
-
-/**
- * @brief Helper variable template.
- * @tparam Type Potential empty type.
- */
-template<typename Type>
-inline constexpr auto is_empty_v = is_empty<Type>::value;
-
-
 /**
  * @brief Transcribes the constness of a type to another type.
  * @tparam To The type to which to transcribe the constness.

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

@@ -698,7 +698,7 @@ private:
 
 /*! @copydoc basic_storage */
 template<typename Entity, typename Type, typename Allocator>
-class basic_storage<Entity, Type, Allocator, std::enable_if_t<is_empty_v<Type>>>: public basic_sparse_set<Entity, typename std::allocator_traits<Allocator>::template rebind_alloc<Entity>> {
+class basic_storage<Entity, Type, Allocator, std::enable_if_t<std::conjunction_v<ENTT_IGNORE_IF_EMPTY, std::is_empty<Type>>>>: public basic_sparse_set<Entity, typename std::allocator_traits<Allocator>::template rebind_alloc<Entity>> {
     using underlying_type = basic_sparse_set<Entity, typename std::allocator_traits<Allocator>::template rebind_alloc<Entity>>;
 
 public: