From 113e5d824fbd3a859ea7f0723433bce344b9b4d5 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 28 Oct 2017 14:16:21 -0400 Subject: [PATCH] Correctly implement FullMatrix::const_iterator::operator++(int). This operator had the wrong return type and was previously unimplemented. --- include/deal.II/lac/full_matrix.h | 14 +++++++++++++- tests/full_matrix/full_matrix_iterator_01.cc | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) 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; } -- 2.39.5