From 1d2a94c38bd513ab0e76a5def067e6ca3d319b08 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 19 May 2009 13:14:54 +0200 Subject: [PATCH] HashTable minor iterator issues - made const_iterator::operator* and const_iterator::operator() const only - added const versions of iterator::operator* and iterator::operator() --- .../HashTables/HashTable/HashTable.H | 7 ++-- .../HashTables/HashTable/HashTableI.H | 32 +++++++++++++++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 826bb95741..0e13b7c9a1 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -330,6 +330,9 @@ public: inline T& operator*(); inline T& operator()(); + inline const T& operator*() const; + inline const T& operator()() const; + inline iterator& operator++(); inline iterator operator++(int); @@ -389,8 +392,8 @@ public: inline bool operator==(const iterator&) const; inline bool operator!=(const iterator&) const; - inline const T& operator*(); - inline const T& operator()(); + inline const T& operator*() const; + inline const T& operator()() const; inline const_iterator& operator++(); inline const_iterator operator++(int); diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index 005979df3f..e2655da433 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -220,16 +220,34 @@ inline bool Foam::HashTable::iterator::operator!= template -inline T& Foam::HashTable::iterator::operator*() +inline T& +Foam::HashTable::iterator::operator*() { return elmtPtr_->obj_; } template -inline T& Foam::HashTable::iterator::operator()() +inline T& +Foam::HashTable::iterator::operator()() { - return operator*(); + return elmtPtr_->obj_; +} + + +template +inline const T& +Foam::HashTable::iterator::operator*() const +{ + return elmtPtr_->obj_; +} + + +template +inline const T& +Foam::HashTable::iterator::operator()() const +{ + return elmtPtr_->obj_; } @@ -410,16 +428,18 @@ inline bool Foam::HashTable::const_iterator::operator!= template -inline const T& Foam::HashTable::const_iterator::operator*() +inline const T& +Foam::HashTable::const_iterator::operator*() const { return elmtPtr_->obj_; } #ifndef __CINT__ template -inline const T& Foam::HashTable::const_iterator::operator()() +inline const T& +Foam::HashTable::const_iterator::operator()() const { - return operator*(); + return elmtPtr_->obj_; } #endif