]> https://gitweb.dealii.org/ - dealii.git/commitdiff
TriaIterator: return a proper Accessor temporary 15445/head
authorMatthias Maier <tamiko@43-1.org>
Thu, 22 Jun 2023 22:35:57 +0000 (17:35 -0500)
committerMatthias Maier <tamiko@43-1.org>
Mon, 3 Jul 2023 23:44:46 +0000 (18:44 -0500)
include/deal.II/grid/tria_iterator.h

index 97d7ef1bbbd6d1ac295b6ae9daea1499f656fd9e..d8485dc87b9823ea5835c2a8a8bd87617e6ba59a 100644 (file)
@@ -319,8 +319,9 @@ public:
    */
   /** @{ */
   /**
-   * Dereferencing operator, returns a reference to an accessor. Usage is thus
-   * like <tt>(*i).index ();</tt>
+   * Dereferencing operator, returns a copy of the underlying accessor for
+   * the cell pointed to by the iterator. Usage is thus like
+   * <tt>(*i).index();</tt>
    *
    * 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 <tt>i->index ();</tt>
+   * Dereferencing operator, returns a reference of the internal accessor
+   * for the cell pointed to by the iterator. Usage is thus like
+   * <tt>i->index();</tt>
    *
    * There is a @p const and a non-@p const version.
    */
@@ -992,7 +988,7 @@ inline TriaRawIterator<Accessor>::TriaRawIterator(
 
 
 template <typename Accessor>
-inline const Accessor &
+inline Accessor
 TriaRawIterator<Accessor>::operator*() const
 {
   Assert(Accessor::structure_dimension != Accessor::dimension ||
@@ -1007,22 +1003,6 @@ TriaRawIterator<Accessor>::operator*() const
 
 
 
-template <typename Accessor>
-inline Accessor &
-TriaRawIterator<Accessor>::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 <typename Accessor>
 inline const Accessor &
 TriaRawIterator<Accessor>::access_any() const
@@ -1036,7 +1016,7 @@ template <typename Accessor>
 inline const Accessor *
 TriaRawIterator<Accessor>::operator->() const
 {
-  return &(this->operator*());
+  return &accessor;
 }
 
 
@@ -1045,7 +1025,7 @@ template <typename Accessor>
 inline Accessor *
 TriaRawIterator<Accessor>::operator->()
 {
-  return &(this->operator*());
+  return &accessor;
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.