type_info: a better operator==
This commit is contained in:
@@ -201,7 +201,7 @@ public:
|
||||
* @return False if the two contents differ, true otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool operator==(const type_info &other) const ENTT_NOEXCEPT {
|
||||
return hash_func == other.hash_func;
|
||||
return (!hash_func && !other.hash_func) || (hash_func && other.hash_func && hash_func() == other.hash_func());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -30,16 +30,20 @@ TEST(TypeName, Functionalities) {
|
||||
}
|
||||
|
||||
TEST(TypeInfo, Functionalities) {
|
||||
static_assert(std::is_default_constructible_v<entt::type_info>);
|
||||
static_assert(std::is_copy_constructible_v<entt::type_info>);
|
||||
static_assert(std::is_move_constructible_v<entt::type_info>);
|
||||
static_assert(std::is_copy_assignable_v<entt::type_info>);
|
||||
static_assert(std::is_move_assignable_v<entt::type_info>);
|
||||
|
||||
ASSERT_EQ(entt::type_info{}, entt::type_info{});
|
||||
ASSERT_NE(entt::type_id<int>(), entt::type_info{});
|
||||
ASSERT_NE(entt::type_id<int>(), entt::type_id<char>());
|
||||
|
||||
auto info = entt::type_id<int>();
|
||||
auto other = entt::type_id(42);
|
||||
entt::type_info empty{};
|
||||
|
||||
static_assert(std::is_default_constructible_v<decltype(info)>);
|
||||
static_assert(std::is_copy_constructible_v<decltype(info)>);
|
||||
static_assert(std::is_move_constructible_v<decltype(info)>);
|
||||
static_assert(std::is_copy_assignable_v<decltype(info)>);
|
||||
static_assert(std::is_move_assignable_v<decltype(info)>);
|
||||
|
||||
ASSERT_EQ(info, other);
|
||||
ASSERT_NE(info, empty);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user