From 6db2e48c0b712efe19af532687bbc132af143a82 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Thu, 22 Jun 2023 17:35:57 -0500 Subject: [PATCH] TriaIterator: return a proper Accessor temporary --- include/deal.II/grid/tria_iterator.h | 40 +++++++--------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/include/deal.II/grid/tria_iterator.h b/include/deal.II/grid/tria_iterator.h index 97d7ef1bbb..d8485dc87b 100644 --- a/include/deal.II/grid/tria_iterator.h +++ b/include/deal.II/grid/tria_iterator.h @@ -319,8 +319,9 @@ public: */ /** @{ */ /** - * Dereferencing operator, returns a reference to an accessor. Usage is thus - * like (*i).index (); + * Dereferencing operator, returns a copy of the underlying accessor for + * the cell pointed to by the iterator. Usage is thus like + * (*i).index(); * * This function has to be specialized explicitly for the different @p * Pointers, to allow an @@ -330,18 +331,13 @@ public: * * You must not dereference invalid or past the end iterators. */ - const Accessor & + Accessor operator*() const; /** - * Dereferencing operator, non-@p const version. - */ - Accessor & - operator*(); - - /** - * Dereferencing operator, returns a reference of the cell pointed to. Usage - * is thus like i->index (); + * Dereferencing operator, returns a reference of the internal accessor + * for the cell pointed to by the iterator. Usage is thus like + * i->index(); * * There is a @p const and a non-@p const version. */ @@ -992,7 +988,7 @@ inline TriaRawIterator::TriaRawIterator( template -inline const Accessor & +inline Accessor TriaRawIterator::operator*() const { Assert(Accessor::structure_dimension != Accessor::dimension || @@ -1007,22 +1003,6 @@ TriaRawIterator::operator*() const -template -inline Accessor & -TriaRawIterator::operator*() -{ - Assert(Accessor::structure_dimension != Accessor::dimension || - state() == IteratorState::valid, - ExcDereferenceInvalidCell(accessor)); - Assert(Accessor::structure_dimension == Accessor::dimension || - state() == IteratorState::valid, - ExcDereferenceInvalidObject(accessor)); - - return accessor; -} - - - template inline const Accessor & TriaRawIterator::access_any() const @@ -1036,7 +1016,7 @@ template inline const Accessor * TriaRawIterator::operator->() const { - return &(this->operator*()); + return &accessor; } @@ -1045,7 +1025,7 @@ template inline Accessor * TriaRawIterator::operator->() { - return &(this->operator*()); + return &accessor; } -- 2.39.5