From 6332c3cf3af28279816eb4ee49af6e29ac3f7a16 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 2 Sep 2021 14:36:35 -0600 Subject: [PATCH] Declare std::iterator_traits for sparse matrix iterators. --- include/deal.II/lac/chunk_sparse_matrix.h | 25 +++++++++++++ include/deal.II/lac/sparse_matrix.h | 24 +++++++++++++ include/deal.II/lac/trilinos_sparse_matrix.h | 38 ++++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/include/deal.II/lac/chunk_sparse_matrix.h b/include/deal.II/lac/chunk_sparse_matrix.h index 402a0c92a4..4d0c1cb275 100644 --- a/include/deal.II/lac/chunk_sparse_matrix.h +++ b/include/deal.II/lac/chunk_sparse_matrix.h @@ -26,6 +26,7 @@ # include # include +# include # include @@ -307,6 +308,12 @@ namespace ChunkSparseMatrixIterators */ using value_type = const Accessor &; + /** + * A type that denotes what data types is used to express the difference + * between two iterators. + */ + using difference_type = types::global_dof_index; + /** * Constructor. Create an iterator into the matrix @p matrix for the given * row and the index within it. @@ -401,6 +408,24 @@ namespace ChunkSparseMatrixIterators } // namespace ChunkSparseMatrixIterators +DEAL_II_NAMESPACE_CLOSE + +namespace std +{ + template + struct iterator_traits< + dealii::ChunkSparseMatrixIterators::Iterator> + { + using iterator_category = forward_iterator_tag; + using value_type = typename dealii::ChunkSparseMatrixIterators:: + Iterator::value_type; + using difference_type = typename dealii::ChunkSparseMatrixIterators:: + Iterator::difference_type; + }; +} // namespace std + +DEAL_II_NAMESPACE_OPEN + /** diff --git a/include/deal.II/lac/sparse_matrix.h b/include/deal.II/lac/sparse_matrix.h index ed2e4c4bce..0c0802efee 100644 --- a/include/deal.II/lac/sparse_matrix.h +++ b/include/deal.II/lac/sparse_matrix.h @@ -30,6 +30,7 @@ # include # endif +# include # include @@ -360,6 +361,10 @@ namespace SparseMatrixIterators */ using value_type = const Accessor &; + /** + * A type that denotes what data types is used to express the difference + * between two iterators. + */ using difference_type = size_type; /** @@ -462,6 +467,25 @@ namespace SparseMatrixIterators } // namespace SparseMatrixIterators +DEAL_II_NAMESPACE_CLOSE + +namespace std +{ + template + struct iterator_traits< + dealii::SparseMatrixIterators::Iterator> + { + using iterator_category = forward_iterator_tag; + using value_type = + typename dealii::SparseMatrixIterators::Iterator::value_type; + using difference_type = typename dealii::SparseMatrixIterators:: + Iterator::difference_type; + }; +} // namespace std + +DEAL_II_NAMESPACE_OPEN + /** * @} */ diff --git a/include/deal.II/lac/trilinos_sparse_matrix.h b/include/deal.II/lac/trilinos_sparse_matrix.h index a8a5566c8f..e2ccc18cc4 100644 --- a/include/deal.II/lac/trilinos_sparse_matrix.h +++ b/include/deal.II/lac/trilinos_sparse_matrix.h @@ -44,6 +44,7 @@ # include # include +# include # include # include # include @@ -209,6 +210,8 @@ namespace TrilinosWrappers value(); }; + + /** * The specialization for a const Accessor. */ @@ -354,6 +357,18 @@ namespace TrilinosWrappers */ using size_type = dealii::types::global_dof_index; + /** + * A type that denotes what data types is used to express the difference + * between two iterators. + */ + using difference_type = dealii::types::global_dof_index; + + /** + * An alias for the type you get when you dereference an iterator of the + * current kind. + */ + using value_type = TrilinosScalar; + /** * Typedef for the matrix type (including constness) we are to operate * on. @@ -443,8 +458,31 @@ namespace TrilinosWrappers }; } // namespace SparseMatrixIterators +} // namespace TrilinosWrappers +DEAL_II_NAMESPACE_CLOSE +namespace std +{ + template + struct iterator_traits< + dealii::TrilinosWrappers::SparseMatrixIterators::Iterator> + { + using iterator_category = forward_iterator_tag; + using value_type = + typename dealii::TrilinosWrappers::SparseMatrixIterators::Iterator< + Constness>::value_type; + using difference_type = + typename dealii::TrilinosWrappers::SparseMatrixIterators::Iterator< + Constness>::difference_type; + }; +} // namespace std + +DEAL_II_NAMESPACE_OPEN + + +namespace TrilinosWrappers +{ /** * This class implements a wrapper to use the Trilinos distributed sparse * matrix class Epetra_FECrsMatrix. This is precisely the kind of matrix we -- 2.39.5