diff --git a/src/entt/core/type_traits.hpp b/src/entt/core/type_traits.hpp index 508eb7610..af8a59ba1 100644 --- a/src/entt/core/type_traits.hpp +++ b/src/entt/core/type_traits.hpp @@ -169,59 +169,6 @@ template constexpr auto is_equality_comparable_v = is_equality_comparable::value; -/*! @brief Traits class used mainly to push things across boundaries. */ -template -struct named_type_traits; - - -/** - * @brief Specialization used to get rid of constness. - * @tparam Type Named type. - */ -template -struct named_type_traits - : named_type_traits -{}; - - -/** - * @brief Helper type. - * @tparam Type Potentially named type. - */ -template -using named_type_traits_t = typename named_type_traits::type; - - -/** - * @brief Helper variable template. - * @tparam Type Potentially named type. - */ -template -constexpr auto named_type_traits_v = named_type_traits::value; - - -/** - * @brief Provides the member constant `value` to true if a given type has a - * name. In all other cases, `value` is false. - * @tparam Type Potentially named type. - */ -template> -struct is_named_type: std::false_type {}; - - -/*! @copydoc is_named_type */ -template -struct is_named_type>>>: std::true_type {}; - - -/** - * @brief Helper variable template. - * @tparam Type Potentially named type. - */ -template -constexpr auto is_named_type_v = is_named_type::value; - - /** * @brief Defines an enum class to use for opaque identifiers and a dedicate * `to_integer` function to convert the identifiers to their underlying type. @@ -239,95 +186,4 @@ constexpr auto is_named_type_v = is_named_type::value; } -/** - * @brief Utility macro to deal with an issue of MSVC. - * - * See _msvc-doesnt-expand-va-args-correctly_ on SO for all the details. - * - * @param args Argument to expand. - */ -#define ENTT_EXPAND(args) args - - -/** - * @brief Makes an already existing type a named type. - * - * The current definition contains a workaround for Clang 6 because it fails to - * deduce correctly the type to use to specialize the class template.
- * With a compiler that fully supports C++17 and works fine with deduction - * guides, the following should be fine instead: - * - * @code{.cpp} - * std::integral_constant - * @endcode - * - * In order to support even sligthly older compilers, I prefer to stick to the - * implementation below. - * - * @param type Type to assign a name to. - */ -#define ENTT_NAMED_TYPE(type)\ - template<>\ - struct entt::named_type_traits\ - : std::integral_constant>>>{#type}>\ - {\ - static_assert(std::is_same_v, type>);\ - static_assert(std::is_object_v);\ - } - - -/** - * @brief Defines a named type (to use for structs). - * @param clazz Name of the type to define. - * @param body Body of the type to define. - */ -#define ENTT_NAMED_STRUCT_ONLY(clazz, body)\ - struct clazz body;\ - ENTT_NAMED_TYPE(clazz) - - -/** - * @brief Defines a named type (to use for structs). - * @param ns Namespace where to define the named type. - * @param clazz Name of the type to define. - * @param body Body of the type to define. - */ -#define ENTT_NAMED_STRUCT_WITH_NAMESPACE(ns, clazz, body)\ - namespace ns { struct clazz body; }\ - ENTT_NAMED_TYPE(ns::clazz) - - -/*! @brief Utility function to simulate macro overloading. */ -#define ENTT_NAMED_STRUCT_OVERLOAD(_1, _2, _3, FUNC, ...) FUNC -/*! @brief Defines a named type (to use for structs). */ -#define ENTT_NAMED_STRUCT(...) ENTT_EXPAND(ENTT_NAMED_STRUCT_OVERLOAD(__VA_ARGS__, ENTT_NAMED_STRUCT_WITH_NAMESPACE, ENTT_NAMED_STRUCT_ONLY,)(__VA_ARGS__)) - - -/** - * @brief Defines a named type (to use for classes). - * @param clazz Name of the type to define. - * @param body Body of the type to define. - */ -#define ENTT_NAMED_CLASS_ONLY(clazz, body)\ - class clazz body;\ - ENTT_NAMED_TYPE(clazz) - - -/** - * @brief Defines a named type (to use for classes). - * @param ns Namespace where to define the named type. - * @param clazz Name of the type to define. - * @param body Body of the type to define. - */ -#define ENTT_NAMED_CLASS_WITH_NAMESPACE(ns, clazz, body)\ - namespace ns { class clazz body; }\ - ENTT_NAMED_TYPE(ns::clazz) - - -/*! @brief Utility function to simulate macro overloading. */ -#define ENTT_NAMED_CLASS_MACRO(_1, _2, _3, FUNC, ...) FUNC -/*! @brief Defines a named type (to use for classes). */ -#define ENTT_NAMED_CLASS(...) ENTT_EXPAND(ENTT_NAMED_CLASS_MACRO(__VA_ARGS__, ENTT_NAMED_CLASS_WITH_NAMESPACE, ENTT_NAMED_CLASS_ONLY,)(__VA_ARGS__)) - - #endif // ENTT_CORE_TYPE_TRAITS_HPP diff --git a/test/entt/core/type_traits.cpp b/test/entt/core/type_traits.cpp index dcdf6fb0b..c1f9f9e00 100644 --- a/test/entt/core/type_traits.cpp +++ b/test/entt/core/type_traits.cpp @@ -1,10 +1,6 @@ #include #include -ENTT_NAMED_TYPE(int); -ENTT_NAMED_STRUCT(named_struct, {}); -ENTT_NAMED_CLASS(named_class, {}); - TEST(Choice, Functionalities) { ASSERT_TRUE((std::is_base_of_v, entt::choice_t<1>>)); ASSERT_FALSE((std::is_base_of_v, entt::choice_t<0>>)); @@ -26,14 +22,3 @@ TEST(IsEqualityComparable, Functionalities) { ASSERT_TRUE(entt::is_equality_comparable_v); ASSERT_FALSE(entt::is_equality_comparable_v); } - -TEST(NamedTypes, Functionalities) { - ASSERT_TRUE(entt::is_named_type_v); - ASSERT_TRUE(entt::is_named_type_v); - ASSERT_TRUE(entt::is_named_type_v); - ASSERT_FALSE(entt::is_named_type_v); - - ASSERT_EQ(entt::named_type_traits_t::value, "int"_hs); - ASSERT_EQ(entt::named_type_traits_t::value, "named_struct"_hs); - ASSERT_EQ(entt::named_type_traits_t::value, "named_class"_hs); -} diff --git a/test/entt/entity/registry.cpp b/test/entt/entity/registry.cpp index 1ee8b71c1..c6868fedc 100644 --- a/test/entt/entity/registry.cpp +++ b/test/entt/entity/registry.cpp @@ -11,7 +11,6 @@ #include ENTT_OPAQUE_TYPE(opaque, std::uint64_t); -ENTT_NAMED_TYPE(int); struct empty_type {}; diff --git a/test/entt/signal/dispatcher.cpp b/test/entt/signal/dispatcher.cpp index 7815152f7..dc99ce333 100644 --- a/test/entt/signal/dispatcher.cpp +++ b/test/entt/signal/dispatcher.cpp @@ -7,8 +7,6 @@ struct an_event {}; struct another_event {}; struct one_more_event {}; -ENTT_NAMED_TYPE(an_event); - struct receiver { static void forward(entt::dispatcher &dispatcher, const an_event &event) { dispatcher.enqueue(event); diff --git a/test/entt/signal/emitter.cpp b/test/entt/signal/emitter.cpp index 7c78e75d1..a54b0a35a 100644 --- a/test/entt/signal/emitter.cpp +++ b/test/entt/signal/emitter.cpp @@ -8,8 +8,6 @@ struct foo_event { int i; char c; }; struct bar_event {}; struct quux_event {}; -ENTT_NAMED_TYPE(foo_event); - TEST(Emitter, Clear) { test_emitter emitter;