From 55b5bb235c8c50a3e2439b2cd234c270ef0d5fe6 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sun, 8 Oct 2017 15:16:15 -0400 Subject: [PATCH] Prefer v.get() to &v[0] with smart pointers. --- .../lac/chunk_sparse_matrix.templates.h | 12 +++---- source/lac/sparsity_pattern.cc | 32 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/deal.II/lac/chunk_sparse_matrix.templates.h b/include/deal.II/lac/chunk_sparse_matrix.templates.h index 18c83e1754..26d5e20a33 100644 --- a/include/deal.II/lac/chunk_sparse_matrix.templates.h +++ b/include/deal.II/lac/chunk_sparse_matrix.templates.h @@ -1580,9 +1580,9 @@ ChunkSparseMatrix::block_write (std::ostream &out) const // first the simple objects, bracketed in [...] out << '[' << max_len << "]["; // then write out real data - out.write (reinterpret_cast(&val[0]), - reinterpret_cast(&val[max_len]) - - reinterpret_cast(&val[0])); + out.write (reinterpret_cast(val.get()), + reinterpret_cast(val.get() + max_len) + - reinterpret_cast(val.get())); out << ']'; AssertThrow (out, ExcIO()); @@ -1612,9 +1612,9 @@ ChunkSparseMatrix::block_read (std::istream &in) val.reset (new number[max_len]); // then read data - in.read (reinterpret_cast(&val[0]), - reinterpret_cast(&val[max_len]) - - reinterpret_cast(&val[0])); + in.read (reinterpret_cast(val.get()), + reinterpret_cast(val.get() + max_len) + - reinterpret_cast(val.get())); in >> c; AssertThrow (c == ']', ExcIO()); } diff --git a/source/lac/sparsity_pattern.cc b/source/lac/sparsity_pattern.cc index 6609d8337d..078c7f7815 100644 --- a/source/lac/sparsity_pattern.cc +++ b/source/lac/sparsity_pattern.cc @@ -339,7 +339,7 @@ SparsityPattern::reinit (const size_type m, ExcInternalError()); // preset the column numbers by a value indicating it is not in use - std::fill_n (&colnums[0], vec_len, invalid_entry); + std::fill_n (colnums.get(), vec_len, invalid_entry); // if diagonal elements are special: let the first entry in each row be the // diagonal value @@ -654,7 +654,7 @@ SparsityPattern::operator () (const size_type i, &colnums[rowstart[i+1]], j); if ((p != &colnums[rowstart[i+1]]) && (*p == j)) - return (p - &colnums[0]); + return (p - colnums.get()); else return invalid_entry; } @@ -783,8 +783,8 @@ SparsityPattern::matrix_position (const std::size_t global_index) const // it is sorted, and since there is an element for the one-past-last row, we // can simply use a bisection search on it const size_type row - = (std::upper_bound (&rowstart[0], &rowstart[rows], global_index) - - &rowstart[0] - 1); + = (std::upper_bound (rowstart.get(), rowstart.get() + rows, global_index) + - rowstart.get() - 1); // now, the column index is simple since that is what the colnums array // stores: @@ -936,13 +936,13 @@ SparsityPattern::block_write (std::ostream &out) const << compressed << ' ' << store_diagonal_first_in_row << "]["; // then write out real data - out.write (reinterpret_cast(&rowstart[0]), - reinterpret_cast(&rowstart[max_dim+1]) - - reinterpret_cast(&rowstart[0])); + out.write (reinterpret_cast(rowstart.get()), + reinterpret_cast(rowstart.get() + max_dim + 1) + - reinterpret_cast(rowstart.get())); out << "]["; - out.write (reinterpret_cast(&colnums[0]), - reinterpret_cast(&colnums[max_vec_len]) - - reinterpret_cast(&colnums[0])); + out.write (reinterpret_cast(colnums.get()), + reinterpret_cast(colnums.get() + max_vec_len) + - reinterpret_cast(colnums.get())); out << ']'; AssertThrow (out, ExcIO()); @@ -978,16 +978,16 @@ SparsityPattern::block_read (std::istream &in) colnums.reset (new size_type[max_vec_len]); // then read data - in.read (reinterpret_cast(&rowstart[0]), - reinterpret_cast(&rowstart[max_dim+1]) - - reinterpret_cast(&rowstart[0])); + in.read (reinterpret_cast(rowstart.get()), + reinterpret_cast(rowstart.get() + max_dim + 1) + - reinterpret_cast(rowstart.get())); in >> c; AssertThrow (c == ']', ExcIO()); in >> c; AssertThrow (c == '[', ExcIO()); - in.read (reinterpret_cast(&colnums[0]), - reinterpret_cast(&colnums[max_vec_len]) - - reinterpret_cast(&colnums[0])); + in.read (reinterpret_cast(colnums.get()), + reinterpret_cast(colnums.get() + max_vec_len) + - reinterpret_cast(colnums.get())); in >> c; AssertThrow (c == ']', ExcIO()); } -- 2.39.5