From a12b99d4d94c106332143f18b0ed7b67c5736440 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sat, 25 Feb 2023 14:46:33 -0700 Subject: [PATCH] Introduce a concept to check for dimensions. --- include/deal.II/base/template_constraints.h | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/deal.II/base/template_constraints.h b/include/deal.II/base/template_constraints.h index fd333a27d1..2f03800ee0 100644 --- a/include/deal.II/base/template_constraints.h +++ b/include/deal.II/base/template_constraints.h @@ -680,6 +680,29 @@ struct EnableIfScalar> }; +/** + * 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 + concept is_valid_dim_spacedim = (dim >= 1 && spacedim <= 3 && + dim <= spacedim); +#endif +} // namespace concepts + + DEAL_II_NAMESPACE_CLOSE #endif -- 2.39.5