From 34f23dc638fba5905a1edb3ebcaf99d6eedabf3c Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Sun, 8 Nov 2015 23:33:33 +0100 Subject: [PATCH 1/1] Replace static const variables with constexpr, where applicable. --- check/time_antipode.cpp | 2 +- check/time_lw_M2.cpp | 2 +- check/time_lw_N.cpp | 2 +- check/time_lw_O.cpp | 2 +- check/time_lw_Q.cpp | 2 +- check/time_lw_Qprime.cpp | 2 +- ginac/archive.cpp | 4 ++-- ginac/inifcns.cpp | 2 +- ginac/parser/parser_compat.cpp | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/check/time_antipode.cpp b/check/time_antipode.cpp index 2358db3e..02ebaf1b 100644 --- a/check/time_antipode.cpp +++ b/check/time_antipode.cpp @@ -46,7 +46,7 @@ using namespace GiNaC; using namespace std; // whether to run this beast or not: -static const bool do_test = true; +constexpr bool do_test = true; // regularization parameter: static const symbol x("x"); diff --git a/check/time_lw_M2.cpp b/check/time_lw_M2.cpp index 4ba122a2..acd2329c 100644 --- a/check/time_lw_M2.cpp +++ b/check/time_lw_M2.cpp @@ -28,7 +28,7 @@ using namespace GiNaC; #include using namespace std; -static const bool do_test = false; // set to true in order to run this beast +constexpr bool do_test = false; // set to true in order to run this beast static unsigned test() { diff --git a/check/time_lw_N.cpp b/check/time_lw_N.cpp index 1fdb4684..c4ad95f9 100644 --- a/check/time_lw_N.cpp +++ b/check/time_lw_N.cpp @@ -30,7 +30,7 @@ using namespace GiNaC; #include using namespace std; -static const bool do_test = false; // set to true in order to run this beast +constexpr bool do_test = false; // set to true in order to run this beast static unsigned test() { diff --git a/check/time_lw_O.cpp b/check/time_lw_O.cpp index 17ab7cb7..715d5019 100644 --- a/check/time_lw_O.cpp +++ b/check/time_lw_O.cpp @@ -29,7 +29,7 @@ using namespace GiNaC; #include using namespace std; -static const bool do_test2 = false; // set to true in order to run this beast +constexpr bool do_test2 = false; // set to true in order to run this beast static const symbol a1("a1"), a2("a2"), a3("a3"), a4("a4"), a5("a5"), a6("a6"); static const symbol b1("b1"), b2("b2"), b3("b3"), b4("b4"), b5("b5"), b6("b6"); diff --git a/check/time_lw_Q.cpp b/check/time_lw_Q.cpp index 184a6268..c109e222 100644 --- a/check/time_lw_Q.cpp +++ b/check/time_lw_Q.cpp @@ -29,7 +29,7 @@ using namespace GiNaC; #include using namespace std; -static const bool do_test = true; // set to true in order to run this beast +const bool do_test = true; // set to true in order to run this beast static unsigned test() { diff --git a/check/time_lw_Qprime.cpp b/check/time_lw_Qprime.cpp index 1ab38dd1..45992a90 100644 --- a/check/time_lw_Qprime.cpp +++ b/check/time_lw_Qprime.cpp @@ -29,7 +29,7 @@ using namespace GiNaC; #include using namespace std; -static const bool do_test = true; // set to true in order to run this beast +const bool do_test = true; // set to true in order to run this beast static unsigned test() { diff --git a/ginac/archive.cpp b/ginac/archive.cpp index 6a973775..b3eea2be 100644 --- a/ginac/archive.cpp +++ b/ginac/archive.cpp @@ -267,8 +267,8 @@ std::istream &operator>>(std::istream &is, archive &ar) is.get(c1); is.get(c2); is.get(c3); is.get(c4); if (c1 != 'G' || c2 != 'A' || c3 != 'R' || c4 != 'C') throw (std::runtime_error("not a GiNaC archive (signature not found)")); - static const unsigned max_version = GINACLIB_ARCHIVE_VERSION; - static const unsigned min_version = GINACLIB_ARCHIVE_VERSION - GINACLIB_ARCHIVE_AGE; + constexpr unsigned max_version = GINACLIB_ARCHIVE_VERSION; + constexpr unsigned min_version = GINACLIB_ARCHIVE_VERSION - GINACLIB_ARCHIVE_AGE; unsigned version = read_unsigned(is); if ((version > max_version) || (version < min_version)) throw (std::runtime_error("archive version " + std::to_string(version) + " cannot be read by this GiNaC library (which supports versions " + std::to_string(min_version) + " thru " + std::to_string(max_version))); diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp index f9305282..9cb5f676 100644 --- a/ginac/inifcns.cpp +++ b/ginac/inifcns.cpp @@ -1218,7 +1218,7 @@ fsolve(const ex& f_in, const symbol& x, const numeric& x1, const numeric& x2) // determined by the secant between the values xx[0] and xx[1]. // Don't set the secant_weight to one because that could disturb // the convergence in some corner cases! - static const double secant_weight = 0.984375; // == 63/64 < 1 + constexpr double secant_weight = 0.984375; // == 63/64 < 1 numeric xxmid = (1-secant_weight)*0.5*(xx[0]+xx[1]) + secant_weight*(xx[0]+fx[0]*(xx[0]-xx[1])/(fx[1]-fx[0])); ex fxmid_ = f.subs(x == xxmid).evalf(); diff --git a/ginac/parser/parser_compat.cpp b/ginac/parser/parser_compat.cpp index 942ec0f7..3678ea8b 100644 --- a/ginac/parser/parser_compat.cpp +++ b/ginac/parser/parser_compat.cpp @@ -34,7 +34,7 @@ static symtab make_symtab(const ex& l); ptr ex::construct_from_string_and_lst(const std::string &s, const ex &l) { - static const bool strict = true; + constexpr bool strict = true; symtab syms = make_symtab(l); parser reader(syms, strict); ex parsed_ex = reader(s); -- 2.44.0