]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce a concept to check for dimensions.
authorWolfgang Bangerth <bangerth@colostate.edu>
Sat, 25 Feb 2023 21:46:33 +0000 (14:46 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 2 Mar 2023 10:26:27 +0000 (03:26 -0700)
include/deal.II/base/template_constraints.h

index fd333a27d1f77beaa419d3ad34502151d1575560..2f03800ee07d1faf31d76d627f81259f7a98d8d0 100644 (file)
@@ -680,6 +680,29 @@ struct EnableIfScalar<std::complex<T>>
 };
 
 
+/**
+ * A namespace that is used to declare concepts used in C++20-style
+ * `requires` clauses.
+ */
+namespace concepts
+{
+#ifdef DEAL_II_HAVE_CXX20
+  /**
+   * A concept that tests that a combination of `dim` and `spacedim`
+   * template arguments is valid. Specifically, we must have that
+   * - `dim>=1`
+   * - `spacedim<=3`
+   * - `dim<=spacedim`.
+   * These are the kinds of requirements that are imposed, for
+   * example, on class Triangulation.
+   */
+  template <int dim, int spacedim>
+  concept is_valid_dim_spacedim = (dim >= 1 && spacedim <= 3 &&
+                                   dim <= spacedim);
+#endif
+} // namespace concepts
+
+
 DEAL_II_NAMESPACE_CLOSE
 
 #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.