Просмотр исходного кода

type_traits: removed container detectors

Michele Caini 5 лет назад
Родитель
Сommit
ab16680cc8
3 измененных файлов с 1 добавлено и 148 удалено
  1. 1 2
      TODO
  2. 0 120
      src/entt/core/type_traits.hpp
  3. 0 26
      test/entt/core/type_traits.cpp

+ 1 - 2
TODO

@@ -28,8 +28,7 @@ Next:
  - meta: update doc
  - static constexpr -> inline constexpr
  - remove internal::find_if
- - use a dedicate class template to specialize meta views for a better support to customizations
  - add const meta container support to meta any
  - meta_any deref fails if operator* returns a temporary
- - remove container detector from type traits (is broken)
  - remove dereferenceable detector from type traits (is broken)
+ - update meta.md

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

@@ -206,126 +206,6 @@ template<class Type>
 inline constexpr auto is_equality_comparable_v = is_equality_comparable<Type>::value;
 
 
-/**
- * @brief Provides the member constant `value` to true if a given type is a
- * container, false otherwise.
- * @tparam Type Potentially container type.
- */
-template<typename Type, typename = void>
-struct is_container: std::false_type {};
-
-
-/*! @copydoc is_container */
-template<typename Type>
-struct is_container<Type, std::void_t<decltype(begin(std::declval<Type>()), end(std::declval<Type>()))>>
-        : std::true_type
-{};
-
-
-/**
- * @brief Helper variable template.
- * @tparam Type Potentially container type.
- */
-template<typename Type>
-inline constexpr auto is_container_v = is_container<Type>::value;
-
-
-/**
- * @brief Provides the member constant `value` to true if a given type is an
- * associative container, false otherwise.
- * @tparam Type Potentially associative container type.
- */
-template<typename, typename = void>
-struct is_associative_container: std::false_type {};
-
-
-/*! @copydoc is_associative_container */
-template<typename Type>
-struct is_associative_container<Type, std::void_t<typename Type::key_type>>
-        : is_container<Type>
-{};
-
-
-/**
- * @brief Helper variable template.
- * @tparam Type Potentially associative container type.
- */
-template<typename Type>
-inline constexpr auto is_associative_container_v = is_associative_container<Type>::value;
-
-
-/**
- * @brief Provides the member constant `value` to true if a given type is a
- * key-only associative container, false otherwise.
- * @tparam Type Potentially key-only associative container type.
- */
-template<typename, typename = void>
-struct is_key_only_associative_container: std::false_type {};
-
-
-/*! @copydoc is_associative_container */
-template<typename Type>
-struct is_key_only_associative_container<Type, std::enable_if_t<std::is_same_v<typename Type::key_type, typename Type::value_type>>>
-        : is_associative_container<Type>
-{};
-
-
-/**
- * @brief Helper variable template.
- * @tparam Type Potentially key-only associative container type.
- */
-template<typename Type>
-inline constexpr auto is_key_only_associative_container_v = is_key_only_associative_container<Type>::value;
-
-
-/**
- * @brief Provides the member constant `value` to true if a given type is a
- * sequence container, false otherwise.
- * @tparam Type Potentially sequence container type.
- */
-template<typename, typename = void>
-struct is_sequence_container: std::false_type {};
-
-
-/*! @copydoc is_sequence_container */
-template<typename Type>
-struct is_sequence_container<Type, std::enable_if_t<!is_associative_container_v<Type>>>
-        : is_container<Type>
-{};
-
-
-/**
- * @brief Helper variable template.
- * @tparam Type Potentially sequence container type.
- */
-template<typename Type>
-inline constexpr auto is_sequence_container_v = is_sequence_container<Type>::value;
-
-
-/**
- * @brief Provides the member constant `value` to true if a given type is a
- * dynamic sequence container, false otherwise.
- * @tparam Type Potentially dynamic sequence container type.
- */
-template<typename, typename = void>
-struct is_dynamic_sequence_container: std::false_type {};
-
-
-/*! @copydoc is_dynamic_sequence_container */
-template<typename Type>
-struct is_dynamic_sequence_container<Type, std::void_t<decltype(std::declval<Type>().insert({}, std::declval<typename Type::value_type>()))>>
-        : is_sequence_container<Type>
-{};
-
-
-/**
- * @brief Helper variable template.
- * @tparam Type Potentially dynamic sequence container type.
- */
-template<typename Type>
-inline constexpr auto is_dynamic_sequence_container_v = is_dynamic_sequence_container<Type>::value;
-
-
 /**
  * @brief Provides the member constant `value` to true if a given type is
  * dereferenceable, false otherwise.

+ 0 - 26
test/entt/core/type_traits.cpp

@@ -52,32 +52,6 @@ TEST(TypeTraits, IsEqualityComparable) {
     ASSERT_FALSE(entt::is_equality_comparable_v<void>);
 }
 
-TEST(TypeTraits, IsContainer) {
-    ASSERT_TRUE(entt::is_container_v<std::vector<int>>);
-    ASSERT_FALSE(entt::is_associative_container_v<std::vector<int>>);
-    ASSERT_FALSE(entt::is_key_only_associative_container_v<std::vector<int>>);
-    ASSERT_TRUE(entt::is_sequence_container_v<std::vector<int>>);
-    ASSERT_TRUE(entt::is_dynamic_sequence_container_v<std::vector<int>>);
-
-    ASSERT_TRUE((entt::is_container_v<std::array<int, 3>>));
-    ASSERT_FALSE((entt::is_associative_container_v<std::array<int, 3>>));
-    ASSERT_FALSE((entt::is_key_only_associative_container_v<std::array<int, 3>>));
-    ASSERT_TRUE((entt::is_sequence_container_v<std::array<int, 3>>));
-    ASSERT_FALSE((entt::is_dynamic_sequence_container_v<std::array<int, 3>>));
-
-    ASSERT_TRUE((entt::is_container_v<std::map<int, char>>));
-    ASSERT_TRUE((entt::is_associative_container_v<std::map<int, char>>));
-    ASSERT_FALSE((entt::is_key_only_associative_container_v<std::map<int, char>>));
-    ASSERT_FALSE((entt::is_sequence_container_v<std::map<int, char>>));
-    ASSERT_FALSE((entt::is_dynamic_sequence_container_v<std::map<int, char>>));
-
-    ASSERT_TRUE(entt::is_container_v<std::set<int>>);
-    ASSERT_TRUE(entt::is_associative_container_v<std::set<int>>);
-    ASSERT_TRUE(entt::is_key_only_associative_container_v<std::set<int>>);
-    ASSERT_FALSE(entt::is_sequence_container_v<std::set<int>>);
-    ASSERT_FALSE(entt::is_dynamic_sequence_container_v<std::set<int>>);
-}
-
 TEST(TypeTraits, IsDereferenceable) {
     ASSERT_TRUE(entt::is_dereferenceable_v<int *>);
     ASSERT_TRUE(entt::is_dereferenceable_v<std::shared_ptr<int>>);