]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a concept for contiguous containers.
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 16 Oct 2023 17:47:53 +0000 (11:47 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 16 Oct 2023 17:47:53 +0000 (11:47 -0600)
include/deal.II/base/template_constraints.h

index 903b4a36bbb4bafd2eef3570bac2df98c604abf0..f2c2f6e9fbe2f53966fc45ca868d6bb399b540f4 100644 (file)
@@ -684,6 +684,27 @@ namespace LinearAlgebra
 namespace concepts
 {
 #if defined(DEAL_II_HAVE_CXX20) || defined(DOXYGEN)
+  /**
+   * A concept that identifies whether a template argument `C`
+   * represents a [contiguous
+   * container](https://en.cppreference.com/w/cpp/named_req/ContiguousContainer).
+   * A contiguous container is a container object (such as `std::vector`,
+   * `std::array`, or `boost::container::small_vector` that stores its elements
+   * in one contiguous array in which we access all elements via a pointer to
+   * the first element plus an offset. In contrast, linked lists, maps, and
+   * similar objects are typically not stored as contiguous containers.
+   */
+  template <typename C>
+  concept is_contiguous_container = requires(C &c) {
+    {
+      std::data(c)
+    };
+    {
+      std::size(c)
+    };
+  };
+
+
   /**
    * A concept that tests that a combination of `dim` and `spacedim`
    * template arguments is valid. Specifically, we must have that

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.