]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid another incorrect use of std::is_trivial. 17936/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 18 Dec 2024 03:38:25 +0000 (20:38 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 18 Dec 2024 03:38:25 +0000 (20:38 -0700)
include/deal.II/lac/sparse_matrix.templates.h

index 2af8a963a4430e89113e82477b0f2b8925199776..67b0c9c74fc61eaa9d4505bbe1c27ee64a282ecb 100644 (file)
@@ -160,30 +160,6 @@ SparseMatrix<number>::~SparseMatrix()
 
 
 
-namespace internal
-{
-  namespace SparseMatrixImplementation
-  {
-    using size_type = types::global_dof_index;
-
-    template <typename T>
-    std::enable_if_t<std::is_trivial_v<T>>
-    zero_subrange(const size_type begin, const size_type end, T *dst)
-    {
-      std::memset(dst + begin, 0, (end - begin) * sizeof(T));
-    }
-
-    template <typename T>
-    std::enable_if_t<!std::is_trivial_v<T>>
-    zero_subrange(const size_type begin, const size_type end, T *dst)
-    {
-      std::fill(dst + begin, dst + end, 0);
-    }
-  } // namespace SparseMatrixImplementation
-} // namespace internal
-
-
-
 template <typename number>
 SparseMatrix<number> &
 SparseMatrix<number>::operator=(const double d)
@@ -210,18 +186,13 @@ SparseMatrix<number>::operator=(const double d)
     parallel::apply_to_subranges(
       0U,
       matrix_size,
-      [this](const size_type begin, const size_type end) {
-        internal::SparseMatrixImplementation::zero_subrange(begin,
-                                                            end,
-                                                            val.get());
+      [values = this->val.get()](const size_type begin, const size_type end) {
+        std::fill(values + begin, values + end, number(0.));
       },
       grain_size);
   else if (matrix_size > 0)
     {
-      if constexpr (std::is_trivial_v<number>)
-        std::memset(val.get(), 0, matrix_size * sizeof(number));
-      else
-        std::fill(val.get(), val.get() + matrix_size, 0);
+      std::fill(val.get(), val.get() + matrix_size, 0);
     }
 
   return *this;
@@ -477,6 +448,8 @@ namespace internal
 {
   namespace SparseMatrixImplementation
   {
+    using size_type = types::global_dof_index;
+
     /**
      * Perform a vmult using the SparseMatrix data structures, but only using
      * a subinterval for the row indices.

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.