]> https://gitweb.dealii.org/ - dealii.git/commitdiff
base/std_cxx17: Make selection of boost/std a configure time constant
authorMatthias Maier <tamiko@43-1.org>
Sun, 24 May 2020 17:02:36 +0000 (12:02 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sun, 24 May 2020 17:09:50 +0000 (12:09 -0500)
Closes #10340

cmake/checks/check_01_cxx_features.cmake
include/deal.II/base/std_cxx17/cmath.h
include/deal.II/base/std_cxx17/optional.h
include/deal.II/base/std_cxx17/tuple.h

index 11b1789e1b435cfd9e0aa3a9c50a803c5ab06a19..88b5ed654178e569c47a3e3b5bb2fc45c0b78135 100644 (file)
@@ -64,12 +64,22 @@ MACRO(_test_cxx17_support)
   # Test that the c++17 attributes are supported.
   CHECK_CXX_SOURCE_COMPILES(
     "
+    #include <cmath>
     #include <iostream>
+    #include <optional>
+    #include <tuple>
 
     #if __cplusplus < 201703L && !defined(_MSC_VER) && !defined(__INTEL_COMPILER)
     #  error \"insufficient support for C++17\"
     #endif
 
+    //check for some C++17 features that we use in our headers:
+    using std::apply;
+    using std::cyl_bessel_j;
+    using std::cyl_bessel_jf;
+    using std::cyl_bessel_jl;
+    using std::optional;
+
     [[nodiscard]] int test_nodiscard()
     {
       return 1;
index 9f31ca42396a06406b0e7b4e5869884af2f8a75d..6695379d2ccba5b9530d0efabb64c34a47bf3f95 100644 (file)
 
 #include <deal.II/base/config.h>
 
-#ifndef __cpp_lib_math_special_functions
+#ifdef DEAL_II_HAVE_CXX17
+#  include <cmath>
+#else
 #  include <boost/math/special_functions/bessel.hpp>
-#endif // __cpp_lib_math_special_functions
+#endif
 
-#include <cmath>
 
 DEAL_II_NAMESPACE_OPEN
 namespace std_cxx17
 {
-#ifndef __cpp_lib_math_special_functions
+#ifndef DEAL_II_HAVE_CXX17
   double (&cyl_bessel_j)(double,
                          double) = boost::math::cyl_bessel_j<double, double>;
   float (&cyl_bessel_jf)(float,
@@ -37,7 +38,7 @@ namespace std_cxx17
   using std::cyl_bessel_j;
   using std::cyl_bessel_jf;
   using std::cyl_bessel_jl;
-#endif // __cpp_lib_math_special_functions
+#endif
 } // namespace std_cxx17
 DEAL_II_NAMESPACE_CLOSE
 
index 52001f9fbca746d6e1e953a0730a4fff25ce04f6..3c9fa30b31ec2288fb1c05233151ca4105ed9c6c 100644 (file)
@@ -17,7 +17,7 @@
 
 #include <deal.II/base/config.h>
 
-#ifdef __cpp_lib_optional
+#ifdef DEAL_II_HAVE_CXX17
 #  include <optional>
 #else
 #  include <boost/optional.hpp>
 DEAL_II_NAMESPACE_OPEN
 namespace std_cxx17
 {
-#ifdef __cpp_lib_optional
-  using std::optional;
-#else
+#ifndef DEAL_II_HAVE_CXX17
   using boost::optional;
+#else
+  using std::optional;
 #endif
 } // namespace std_cxx17
 DEAL_II_NAMESPACE_CLOSE
index 878bf6b3572fad608784d7105b8361da88e15feb..93474c521e355f1f536d6e1eb493ab75412457e7 100644 (file)
 
 #include <tuple>
 
-#ifndef __cpp_lib_apply
-#  include <utility>
-#endif // __cpp_lib_apply
-
 DEAL_II_NAMESPACE_OPEN
 namespace std_cxx17
 {
-#ifndef __cpp_lib_apply
+#ifndef DEAL_II_HAVE_CXX17
   template <typename F, typename Tuple, size_t... S>
   auto
   apply_impl(F &&fn, Tuple &&t, std::index_sequence<S...>)
@@ -51,7 +47,7 @@ namespace std_cxx17
   }
 #else
   using std::apply;
-#endif // __cpp_lib_apply
+#endif
 } // namespace std_cxx17
 DEAL_II_NAMESPACE_CLOSE
 

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.