From: Matthias Maier Date: Thu, 22 Jun 2023 22:35:57 +0000 (-0500) Subject: TriaIterator: return a proper Accessor temporary X-Git-Tag: relicensing~749^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15445%2Fhead;p=dealii.git TriaIterator: return a proper Accessor temporary --- 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; }