From d48d9466af6d9f4fcdc4c8476e1cd49180dd21ca Mon Sep 17 00:00:00 2001 From: Hans-Christian Ebke Date: Wed, 7 Aug 2013 09:24:06 +0000 Subject: [PATCH] Fixing operator-> in circulators. git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@895 fdac6126-5c0c-442c-9429-916003d36597 --- src/OpenMesh/Core/Mesh/CirculatorsT.hh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/CirculatorsT.hh b/src/OpenMesh/Core/Mesh/CirculatorsT.hh index 28dd793d..10ce1b09 100644 --- a/src/OpenMesh/Core/Mesh/CirculatorsT.hh +++ b/src/OpenMesh/Core/Mesh/CirculatorsT.hh @@ -283,9 +283,17 @@ class GenericCirculatorT : protected GenericCirculatorBaseT { #endif } - /// Standard pointer operator. - value_type operator->() const { - return **this; + /** + * @brief Pointer dereferentiation. + * + * This returns a pointer which points to a handle + * that loses its validity once this dereferentiation is + * invoked again. Thus, do not store the result of + * this operation. + */ + pointer operator->() const { + pointer_deref_value = **this; + return &pointer_deref_value; } GenericCirculatorT &operator=(const GenericCirculatorT &rhs) { @@ -332,6 +340,8 @@ class GenericCirculatorT : protected GenericCirculatorBaseT { return s << self.mesh_ << ", " << self.start_.idx() << ", " << self.heh_.idx() << ", " << self.lap_counter_; } + private: + mutable value_type pointer_deref_value; }; } // namespace Iterators