]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Mark some variables as constexpr. 11286/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 1 Dec 2020 02:47:01 +0000 (19:47 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 1 Dec 2020 02:47:26 +0000 (19:47 -0700)
These are global variables, and as such should not actually have been declared in
a header file without marking them as 'extern' and providing a definition in a .cc file.
If the compiler had not inlined the definitions of these variables, we would have
gotten duplicate symbol linker errors. C++11 provides us with a way around this:
mark these variables as 'constexpr', thereby avoiding the bug we currently have.

include/deal.II/base/std_cxx17/cmath.h

index bf0f8e93badb8c50779440f524d7c0928e8d53a8..756ba5ed6e381dfddd0e7d8fdead35f412d0a09c 100644 (file)
@@ -28,11 +28,11 @@ DEAL_II_NAMESPACE_OPEN
 namespace std_cxx17
 {
 #ifndef DEAL_II_HAVE_CXX17_BESSEL_FUNCTIONS
-  double (&cyl_bessel_j)(double,
-                         double) = boost::math::cyl_bessel_j<double, double>;
-  float (&cyl_bessel_jf)(float,
-                         float)  = boost::math::cyl_bessel_j<float, float>;
-  long double (&cyl_bessel_jl)(long double, long double) =
+  constexpr double (&cyl_bessel_j)(double, double) =
+    boost::math::cyl_bessel_j<double, double>;
+  constexpr float (&cyl_bessel_jf)(float, float) =
+    boost::math::cyl_bessel_j<float, float>;
+  constexpr long double (&cyl_bessel_jl)(long double, long double) =
     boost::math::cyl_bessel_j<long double, long double>;
 #else
   using std::cyl_bessel_j;

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.