From: Wolfgang Bangerth Date: Fri, 27 Aug 2021 17:23:51 +0000 (-0600) Subject: Use std::next instead of ++object.begin(). X-Git-Tag: v9.4.0-rc1~1007^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=716978ba09dc8e725b02aac6073421858e362197;p=dealii.git Use std::next instead of ++object.begin(). --- diff --git a/include/deal.II/base/iterator_range.h b/include/deal.II/base/iterator_range.h index 5d8043308a..1f1682645f 100644 --- a/include/deal.II/base/iterator_range.h +++ b/include/deal.II/base/iterator_range.h @@ -114,10 +114,11 @@ class IteratorOverIterators; * way that if you dereference the result of IteratorRange::begin(), * you get the b iterator. Furthermore, you must be able to * increment the object returned by IteratorRange::begin() so that - * *(++begin()) == b+1. In other words, IteratorRange::begin() - * must return an iterator that when dereferenced returns an iterator of the - * template type Iterator: It is an iterator over iterators in - * the same sense as if you had a pointer into an array of pointers. + * *(std::next(begin())) == b+1. In other words, + * IteratorRange::begin() must return an iterator that when dereferenced returns + * an iterator of the template type Iterator: It is an iterator + * over iterators in the same sense as if you had a pointer into an array of + * pointers. * * This is implemented in the form of the IteratorRange::IteratorOverIterators * class. diff --git a/include/deal.II/lac/block_indices.h b/include/deal.II/lac/block_indices.h index a24c07dc95..1c1315b4e2 100644 --- a/include/deal.II/lac/block_indices.h +++ b/include/deal.II/lac/block_indices.h @@ -331,8 +331,9 @@ BlockIndices::global_to_local(const size_type i) const Assert(n_blocks > 0, ExcLowerRangeType(i, size_type(1))); // start_indices[0] == 0 so we might as well start from the next one - const auto it = - --std::upper_bound(++start_indices.begin(), start_indices.end(), i); + const auto it = --std::upper_bound(std::next(start_indices.begin()), + start_indices.end(), + i); return {std::distance(start_indices.begin(), it), i - *it}; } diff --git a/tests/bits/chunk_sparse_matrix_iterator_11.cc b/tests/bits/chunk_sparse_matrix_iterator_11.cc index 6894f8ddf8..0a9062a16e 100644 --- a/tests/bits/chunk_sparse_matrix_iterator_11.cc +++ b/tests/bits/chunk_sparse_matrix_iterator_11.cc @@ -39,7 +39,7 @@ test(const unsigned int chunk_size) // attach a sparse matrix to it ChunkSparseMatrix A(sparsity); - ChunkSparseMatrix::iterator k = A.begin(), j = ++A.begin(); + ChunkSparseMatrix::iterator k = A.begin(), j = std::next(A.begin()); AssertThrow(k < j, ExcInternalError()); AssertThrow(j > k, ExcInternalError()); diff --git a/tests/bits/chunk_sparse_matrix_iterator_12.cc b/tests/bits/chunk_sparse_matrix_iterator_12.cc index f35c1b7750..c72f7a9ab0 100644 --- a/tests/bits/chunk_sparse_matrix_iterator_12.cc +++ b/tests/bits/chunk_sparse_matrix_iterator_12.cc @@ -38,7 +38,8 @@ test(const unsigned int chunk_size) // attach a sparse matrix to it ChunkSparseMatrix A(sparsity); - ChunkSparseMatrix::const_iterator k = A.begin(), j = ++A.begin(); + ChunkSparseMatrix::const_iterator k = A.begin(), + j = std::next(A.begin()); AssertThrow(k < j, ExcInternalError()); AssertThrow(j > k, ExcInternalError()); diff --git a/tests/bits/sparse_matrix_iterator_11.cc b/tests/bits/sparse_matrix_iterator_11.cc index 1449d167b2..23bdfaac74 100644 --- a/tests/bits/sparse_matrix_iterator_11.cc +++ b/tests/bits/sparse_matrix_iterator_11.cc @@ -37,7 +37,7 @@ test() // attach a sparse matrix to it SparseMatrix A(sparsity); - SparseMatrix::iterator k = A.begin(), j = ++A.begin(); + SparseMatrix::iterator k = A.begin(), j = std::next(A.begin()); AssertThrow(k < j, ExcInternalError()); AssertThrow(j > k, ExcInternalError()); diff --git a/tests/bits/sparse_matrix_iterator_12.cc b/tests/bits/sparse_matrix_iterator_12.cc index da1e6aa040..eac35f607c 100644 --- a/tests/bits/sparse_matrix_iterator_12.cc +++ b/tests/bits/sparse_matrix_iterator_12.cc @@ -37,7 +37,7 @@ test() // attach a sparse matrix to it SparseMatrix A(sparsity); - SparseMatrix::const_iterator k = A.begin(), j = ++A.begin(); + SparseMatrix::const_iterator k = A.begin(), j = std::next(A.begin()); AssertThrow(k < j, ExcInternalError()); AssertThrow(j > k, ExcInternalError()); diff --git a/tests/dofs/n_boundary_dofs_03.cc b/tests/dofs/n_boundary_dofs_03.cc index 81437e5183..193afebbfe 100644 --- a/tests/dofs/n_boundary_dofs_03.cc +++ b/tests/dofs/n_boundary_dofs_03.cc @@ -60,8 +60,8 @@ test() // assign boundary ids triangulation.begin()->face(0)->set_boundary_id(12); triangulation.begin()->face(1)->set_boundary_id(13); - (++triangulation.begin())->face(0)->set_boundary_id(14); - (++triangulation.begin())->face(1)->set_boundary_id(15); + std::next(triangulation.begin())->face(0)->set_boundary_id(14); + std::next(triangulation.begin())->face(1)->set_boundary_id(15); FESystem<1, spacedim> fe(FE_Q<1, spacedim>(1), 1, FE_DGQ<1, spacedim>(1), 1); diff --git a/tests/full_matrix/full_matrix_iterator_01.cc b/tests/full_matrix/full_matrix_iterator_01.cc index d53e44060b..8ff603e422 100644 --- a/tests/full_matrix/full_matrix_iterator_01.cc +++ b/tests/full_matrix/full_matrix_iterator_01.cc @@ -29,7 +29,7 @@ test() FullMatrix A(3, 3); // test prefix operator - const IteratorType k = A.begin(), j = ++A.begin(); + const IteratorType k = A.begin(), j = std::next(A.begin()); AssertThrow(k < j, ExcInternalError()); AssertThrow(j > k, ExcInternalError()); diff --git a/tests/hp/n_boundary_dofs_03.cc b/tests/hp/n_boundary_dofs_03.cc index 8c8381419f..90df8fd7fe 100644 --- a/tests/hp/n_boundary_dofs_03.cc +++ b/tests/hp/n_boundary_dofs_03.cc @@ -62,8 +62,8 @@ test() // assign boundary ids triangulation.begin()->face(0)->set_boundary_id(12); triangulation.begin()->face(1)->set_boundary_id(13); - (++triangulation.begin())->face(0)->set_boundary_id(14); - (++triangulation.begin())->face(1)->set_boundary_id(15); + std::next(triangulation.begin())->face(0)->set_boundary_id(14); + std::next(triangulation.begin())->face(1)->set_boundary_id(15); hp::FECollection<1, spacedim> fe; diff --git a/tests/trilinos/trilinos_sparse_matrix_iterator_11.cc b/tests/trilinos/trilinos_sparse_matrix_iterator_11.cc index 4de8b31b3c..44e944b1e4 100644 --- a/tests/trilinos/trilinos_sparse_matrix_iterator_11.cc +++ b/tests/trilinos/trilinos_sparse_matrix_iterator_11.cc @@ -38,7 +38,8 @@ test() // attach a sparse matrix to it TrilinosWrappers::SparseMatrix A(sparsity); - TrilinosWrappers::SparseMatrix::iterator k = A.begin(), j = ++A.begin(); + TrilinosWrappers::SparseMatrix::iterator k = A.begin(), + j = std::next(A.begin()); AssertThrow(k < j, ExcInternalError()); AssertThrow(j > k, ExcInternalError()); diff --git a/tests/trilinos/trilinos_sparse_matrix_iterator_12.cc b/tests/trilinos/trilinos_sparse_matrix_iterator_12.cc index 177514f48d..ff4a2755da 100644 --- a/tests/trilinos/trilinos_sparse_matrix_iterator_12.cc +++ b/tests/trilinos/trilinos_sparse_matrix_iterator_12.cc @@ -38,7 +38,8 @@ test() // attach a sparse matrix to it TrilinosWrappers::SparseMatrix A(sparsity); - TrilinosWrappers::SparseMatrix::const_iterator k = A.begin(), j = ++A.begin(); + TrilinosWrappers::SparseMatrix::const_iterator k = A.begin(), + j = std::next(A.begin()); AssertThrow(k < j, ExcInternalError()); AssertThrow(j > k, ExcInternalError());