From f9ac4c7aaa6164fca5e17f1b1dafea5f80c4b81b Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 26 Jan 2018 08:51:55 -0700 Subject: [PATCH] Specialize ArrayViewHelper::is_contiguous() for pointers. --- include/deal.II/base/array_view.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/include/deal.II/base/array_view.h b/include/deal.II/base/array_view.h index 33e0e08484..04648f3d16 100644 --- a/include/deal.II/base/array_view.h +++ b/include/deal.II/base/array_view.h @@ -429,7 +429,12 @@ namespace internal { namespace ArrayViewHelper { - template + /** + * Return whether the objects one gets by dereferencing the + * iterators within the given iterator range form a contiguous + * range in memory. + */ + template 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 + constexpr + bool is_contiguous(T *, + T *) + { + return true; + } } } #endif -- 2.39.5