From: David Wells Date: Sat, 28 Oct 2017 18:16:21 +0000 (-0400) Subject: Correctly implement FullMatrix::const_iterator::operator++(int). X-Git-Tag: v9.0.0-rc1~854^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=113e5d824fbd3a859ea7f0723433bce344b9b4d5;p=dealii.git Correctly implement FullMatrix::const_iterator::operator++(int). This operator had the wrong return type and was previously unimplemented. --- diff --git a/include/deal.II/lac/full_matrix.h b/include/deal.II/lac/full_matrix.h index 351e2dd6c1..9b3e315a59 100644 --- a/include/deal.II/lac/full_matrix.h +++ b/include/deal.II/lac/full_matrix.h @@ -165,7 +165,7 @@ public: /** * Postfix increment. */ - const_iterator &operator++ (int); + const_iterator operator++ (int); /** * Dereferencing operator. @@ -1379,6 +1379,18 @@ FullMatrix::const_iterator::operator++ () } +template +inline +typename FullMatrix::const_iterator +FullMatrix::const_iterator::operator++ (int) +{ + const typename FullMatrix::const_iterator current = *this; + ++(*this); + + return current; +} + + template inline const typename FullMatrix::Accessor & diff --git a/tests/full_matrix/full_matrix_iterator_01.cc b/tests/full_matrix/full_matrix_iterator_01.cc index 19123c6f3c..63160feba6 100644 --- a/tests/full_matrix/full_matrix_iterator_01.cc +++ b/tests/full_matrix/full_matrix_iterator_01.cc @@ -25,6 +25,7 @@ void test () { FullMatrix A(3,3); + // test prefix operator const FullMatrix::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::const_iterator l = A.begin(); + FullMatrix::const_iterator m = l++; + + AssertThrow(m == k, ExcInternalError()); + AssertThrow(l > m, ExcInternalError()); + AssertThrow(l->column() == k->column() + 1, ExcInternalError()); + + deallog << "OK" << std::endl; }