]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a check for concepts to the C++20 test. 14836/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 2 Mar 2023 10:26:09 +0000 (03:26 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 2 Mar 2023 10:26:28 +0000 (03:26 -0700)
cmake/checks/check_01_cxx_features.cmake

index e7793e49b038cb1ffc56ec30ef53d82feb859bd8..b6b9a0b28a0300f17f03d803dac250b2c6635b55 100644 (file)
@@ -66,6 +66,8 @@ macro(_test_cxx20_support)
   # of the C++20 standard (which will have "202002L" when finalized). gcc-10
   # exports this version number when configured with C++20 support.
   # clang-10 exports the final "202002L" version instead, as does gcc-11.
+  #
+  # Beyond this, check for some features we actually need.
   CHECK_CXX_SOURCE_COMPILES(
     "
     #include <cmath>
@@ -79,6 +81,20 @@ macro(_test_cxx20_support)
     #  error \"insufficient support for C++20\"
     #endif
 
+
+    // Test concepts and requires clauses
+    template <int dim, int spacedim>
+    concept is_valid_dim_spacedim = (dim >= 1 && spacedim <= 3 &&
+                                     dim <= spacedim);
+
+    template <int dim, int spacedim>
+    requires is_valid_dim_spacedim<dim,spacedim>
+    class Triangulation 
+    {};
+
+    Triangulation<1,3> t;
+
+
     int main()
     {
     }

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.