]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Correctly implement FullMatrix<T>::const_iterator::operator++(int).
authorDavid Wells <wellsd2@rpi.edu>
Sat, 28 Oct 2017 18:16:21 +0000 (14:16 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Sat, 28 Oct 2017 18:16:21 +0000 (14:16 -0400)
This operator had the wrong return type and was previously unimplemented.

include/deal.II/lac/full_matrix.h
tests/full_matrix/full_matrix_iterator_01.cc

index 351e2dd6c165da0392ff41df32137e410aac0d1b..9b3e315a5962a2ce3fc25d440b58daee87ae4c9c 100644 (file)
@@ -165,7 +165,7 @@ public:
     /**
      * Postfix increment.
      */
-    const_iterator &operator++ (int);
+    const_iterator operator++ (int);
 
     /**
      * Dereferencing operator.
@@ -1379,6 +1379,18 @@ FullMatrix<number>::const_iterator::operator++ ()
 }
 
 
+template <typename number>
+inline
+typename FullMatrix<number>::const_iterator
+FullMatrix<number>::const_iterator::operator++ (int)
+{
+  const typename FullMatrix<number>::const_iterator current = *this;
+  ++(*this);
+
+  return current;
+}
+
+
 template <typename number>
 inline
 const typename FullMatrix<number>::Accessor &
index 19123c6f3c2ba7c3ad59405b9fce474fdcadf8f0..63160feba624075ad392d4d68f3fd5f6c20f2dd2 100644 (file)
@@ -25,6 +25,7 @@ void test ()
 {
   FullMatrix<double> A(3,3);
 
+  // test prefix operator
   const FullMatrix<double>::const_iterator k = A.begin(),
                                            j = ++A.begin();
 
@@ -40,6 +41,15 @@ void test ()
   AssertThrow (k == k, ExcInternalError());
   AssertThrow (!(k != k), ExcInternalError());
 
+  // test postfix operator
+  FullMatrix<double>::const_iterator l = A.begin();
+  FullMatrix<double>::const_iterator m = l++;
+
+  AssertThrow(m == k, ExcInternalError());
+  AssertThrow(l > m, ExcInternalError());
+  AssertThrow(l->column() == k->column() + 1, ExcInternalError());
+
+
   deallog << "OK" << std::endl;
 }
 

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.