diff --git a/src/entt/core/type_traits.hpp b/src/entt/core/type_traits.hpp index b81ce3026..6bd94e92f 100644 --- a/src/entt/core/type_traits.hpp +++ b/src/entt/core/type_traits.hpp @@ -290,6 +290,31 @@ template inline constexpr auto type_list_contains_v = type_list_contains::value; +/*! @brief Primary template isn't defined on purpose. */ +template +struct type_list_diff; + + +/** + * @brief Computes the difference between two type lists. + * @tparam Type Types provided by the first type list. + * @tparam Other Types provided by the second type list. + */ +template +struct type_list_diff, type_list> { + /*! @brief A type list that is the difference between the two type lists. */ + using type = type_list_cat_t, Type>, type_list<>, type_list>...>; +}; + + +/** + * @brief Helper type. + * @tparam List Type lists between which to compute the difference. + */ +template +using type_list_diff_t = typename type_list_diff::type; + + /** * @brief A class to use to push around lists of constant values, nothing more. * @tparam Value Values provided by the value list. diff --git a/test/entt/core/type_traits.cpp b/test/entt/core/type_traits.cpp index bbaabcd57..0f34d8827 100644 --- a/test/entt/core/type_traits.cpp +++ b/test/entt/core/type_traits.cpp @@ -64,6 +64,12 @@ TEST(TypeTraits, TypeList) { static_assert(std::is_same_v, int>); static_assert(std::is_same_v, char>); static_assert(std::is_same_v, double>); + + static_assert(std::is_same_v, entt::type_list>, entt::type_list>); + static_assert(std::is_same_v, entt::type_list>, entt::type_list<>>); + static_assert(std::is_same_v, entt::type_list>, entt::type_list>); + static_assert(std::is_same_v, entt::type_list>, entt::type_list>); + static_assert(std::is_same_v, entt::type_list>, entt::type_list>); } TEST(TypeTraits, ValueList) {