]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Specialize ArrayViewHelper::is_contiguous() for pointers.
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 26 Jan 2018 15:51:55 +0000 (08:51 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 27 Jan 2018 01:17:47 +0000 (18:17 -0700)
include/deal.II/base/array_view.h

index 33e0e0848473051f0750aa9ddb37db9414b99eb2..04648f3d168cbb076d08d24f15d05f12f0a8744b 100644 (file)
@@ -429,7 +429,12 @@ namespace internal
 {
   namespace ArrayViewHelper
   {
-    template<class Iterator>
+    /**
+     * Return whether the objects one gets by dereferencing the
+     * iterators within the given iterator range form a contiguous
+     * range in memory.
+     */
+    template <class Iterator>
     bool is_contiguous(const Iterator &first, const Iterator &last)
     {
       const auto n = std::distance(first, last);
@@ -438,6 +443,25 @@ namespace internal
           return false;
       return true;
     }
+
+
+    /**
+     * Return whether the objects one gets by dereferencing the
+     * iterators within the given iterator range form a contiguous
+     * range in memory.
+     *
+     * This specialization for (@p const or non-@p const) pointers
+     * returns @p true unconditionally since the fact that objects
+     * pointed to by pointers are contiguous is embedded in the memory
+     * model of C++.
+     */
+    template <class T>
+    constexpr
+    bool is_contiguous(T *,
+                       T *)
+    {
+      return true;
+    }
   }
 }
 #endif

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.