]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Declare std::iterator_traits for sparse matrix iterators.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 2 Sep 2021 20:36:35 +0000 (14:36 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 2 Sep 2021 20:36:56 +0000 (14:36 -0600)
include/deal.II/lac/chunk_sparse_matrix.h
include/deal.II/lac/sparse_matrix.h
include/deal.II/lac/trilinos_sparse_matrix.h

index 402a0c92a489c7bccdd18ed0e174732e32450c95..4d0c1cb275efb000cbf0e5ac6145448876d1618a 100644 (file)
@@ -26,6 +26,7 @@
 #  include <deal.II/lac/exceptions.h>
 #  include <deal.II/lac/identity_matrix.h>
 
+#  include <iterator>
 #  include <memory>
 
 
@@ -307,6 +308,12 @@ namespace ChunkSparseMatrixIterators
      */
     using value_type = const Accessor<number, Constness> &;
 
+    /**
+     * 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 <typename number, bool Constness>
+  struct iterator_traits<
+    dealii::ChunkSparseMatrixIterators::Iterator<number, Constness>>
+  {
+    using iterator_category = forward_iterator_tag;
+    using value_type        = typename dealii::ChunkSparseMatrixIterators::
+      Iterator<number, Constness>::value_type;
+    using difference_type = typename dealii::ChunkSparseMatrixIterators::
+      Iterator<number, Constness>::difference_type;
+  };
+} // namespace std
+
+DEAL_II_NAMESPACE_OPEN
+
 
 
 /**
index ed2e4c4bcec5eb26bef79b2bd82c0e33e5a06b59..0c0802efee3d6e41feaee9ae70d80ad6188e3cfb 100644 (file)
@@ -30,6 +30,7 @@
 #    include <mpi.h>
 #  endif
 
+#  include <iterator>
 #  include <memory>
 
 
@@ -360,6 +361,10 @@ namespace SparseMatrixIterators
      */
     using value_type = const Accessor<number, Constness> &;
 
+    /**
+     * 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 <typename number, bool Constness>
+  struct iterator_traits<
+    dealii::SparseMatrixIterators::Iterator<number, Constness>>
+  {
+    using iterator_category = forward_iterator_tag;
+    using value_type =
+      typename dealii::SparseMatrixIterators::Iterator<number,
+                                                       Constness>::value_type;
+    using difference_type = typename dealii::SparseMatrixIterators::
+      Iterator<number, Constness>::difference_type;
+  };
+} // namespace std
+
+DEAL_II_NAMESPACE_OPEN
+
 /**
  * @}
  */
index a8a5566c8f287fd1f959d71b7df6071d8d8f53e0..e2ccc18cc425e430ac2742928b97f95dc12376b6 100644 (file)
@@ -44,6 +44,7 @@
 #    include <mpi.h>
 
 #    include <cmath>
+#    include <iterator>
 #    include <memory>
 #    include <type_traits>
 #    include <vector>
@@ -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 <bool Constness>
+  struct iterator_traits<
+    dealii::TrilinosWrappers::SparseMatrixIterators::Iterator<Constness>>
+  {
+    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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.