diff --git a/applications/test/HashSet/Test-hashSet.C b/applications/test/HashSet/Test-hashSet.C index eeae7ff0d0b44e3e9471fda74b00d6b5b9036ed8..a4593d9dafb9f157d1edb9d0839131085b75764f 100644 --- a/applications/test/HashSet/Test-hashSet.C +++ b/applications/test/HashSet/Test-hashSet.C @@ -40,7 +40,7 @@ using namespace Foam; template<class Iter> void printIf(const Iter& iter) { - if (iter.found()) + if (iter) { Info<< *iter; } diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 7b5e2afb2e4d752168762f9799c8a64118623ea0..323d5450f03ff226c32127ddbac6f30770e0320b 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -685,8 +685,13 @@ protected: //- The key associated with the iterator inline const Key& key() const; + // Member Operators + //- True if iterator points to an entry + // This can be used directly instead of comparing to end() + explicit inline operator bool() const noexcept; + //- Compare hash-entry element pointers. // Independent of const/non-const access inline bool operator==(const Iterator<true>& iter) const; diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIterI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIterI.H index cc85a8b91402983e50ebdcb5ce73594a837ada46..93132e2bc178fb5e5b6730f903a59f3ea925087e 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIterI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIterI.H @@ -124,6 +124,15 @@ inline const Key& Foam::HashTable<T, Key, Hash>::Iterator<Const>::key() const } +template<class T, class Key, class Hash> +template<bool Const> +inline Foam::HashTable<T, Key, Hash>::Iterator<Const>::operator +bool() const noexcept +{ + return entry_; +} + + template<class T, class Key, class Hash> template<bool Const> inline bool Foam::HashTable<T, Key, Hash>::Iterator<Const>::operator==