From 5983c44e6f7e99a6efe226ba9f57115c682bde1a Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 16 Oct 2023 11:47:53 -0600 Subject: [PATCH] Add a concept for contiguous containers. --- include/deal.II/base/template_constraints.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/deal.II/base/template_constraints.h b/include/deal.II/base/template_constraints.h index 903b4a36bb..f2c2f6e9fb 100644 --- a/include/deal.II/base/template_constraints.h +++ b/include/deal.II/base/template_constraints.h @@ -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 + 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 -- 2.39.5