Browse Source

Fix c++20 -Wambiguous-reversed-operator in hashtable (#1766)

Fix for build errors like
...\Jolt\Core\Factory.cpp:22:11: error: ISO C++20 considers use of overloaded operator '!=' (with operand types 'ClassNameMap::iterator' (aka 'JPH::HashTable<std::basic_string_view<char>, std::pair<std::basic_string_view<char>, const JPH::RTTI *>, JPH::UnorderedMapDetail<std::basic_string_view<char>, const JPH::RTTI *>, JPH::Hash<std::string_view>, std::equal_to<std::basic_string_view<char>>>::iterator') and 'JPH::HashTable<std::basic_string_view<char>, std::pair<std::basic_string_view<char>, const JPH::RTTI *>, JPH::UnorderedMapDetail<std::basic_string_view<char>, const JPH::RTTI *>, JPH::Hash<std::string_view>, std::equal_to<std::basic_string_view<char>>>::iterator') to be ambiguous despite there being a unique best viable function with non-reversed arguments [-Werror,-Wambiguous-reversed-operator]
        return c != mClassNameMap.end()? c->second : nullptr;

Related
https://stackoverflow.com/a/60387060
virtul 2 weeks ago
parent
commit
589106a492
1 changed files with 4 additions and 0 deletions
  1. 4 0
      Jolt/Core/HashTable.h

+ 4 - 0
Jolt/Core/HashTable.h

@@ -364,6 +364,8 @@ public:
 		using Base = IteratorBase<HashTable, iterator>;
 
 	public:
+		using IteratorBase<HashTable, iterator>::operator ==;
+
 		/// Properties
 		using reference = typename Base::value_type &;
 		using pointer = typename Base::value_type *;
@@ -401,6 +403,8 @@ public:
 		using Base = IteratorBase<const HashTable, const_iterator>;
 
 	public:
+		using IteratorBase<const HashTable, const_iterator>::operator ==;
+
 		/// Properties
 		using reference = const typename Base::value_type &;
 		using pointer = const typename Base::value_type *;