1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-20 08:27:39 +00:00

Change static const to static constexpr wherever possible

Since we require C++11, most of these consts can be constexpr.

Two `static const ld` remain non-compile-time-evaluable because
they depend on the runtime `log` function. One `static const cld`
remains non-compile-time because `std::complex<T>` doesn't become
constexpr until C++14.
This commit is contained in:
Arthur O'Dwyer
2023-08-23 09:44:37 -08:00
parent b70b339f52
commit 62629f3e70
48 changed files with 453 additions and 458 deletions

14
hyper.h
View File

@@ -550,7 +550,7 @@ public:
using purehookset = hookset<void()>;
static const int NOHINT = -1;
static constexpr int NOHINT = -1;
typedef function<void()> reaction_t;
typedef function<bool()> bool_reaction_t;
@@ -664,7 +664,7 @@ struct finalizer {
~finalizer() { f(); }
};
static const int MAXPLAYER = 7;
static constexpr int MAXPLAYER = 7;
#define DEFAULTCONTROL (multi::players == 1 && !shmup::on && !multi::alwaysuse)
#define DEFAULTNOR(sym) (DEFAULTCONTROL || multi::notremapped(sym))
@@ -776,7 +776,7 @@ enum orbAction { roMouse, roKeyboard, roCheck, roMouseForce, roMultiCheck, roMul
#endif
#define pmodel (pconf.model)
static const int DISTANCE_UNKNOWN = 127;
static constexpr int DISTANCE_UNKNOWN = 127;
template<class T, class U> int addHook(hookset<T>& m, int prio, U&& hook) {
return m.add(prio, static_cast<U&&>(hook));
@@ -860,9 +860,9 @@ template<class T, class U> void eliminate_if(vector<T>& data, U pred) {
data[i] = data.back(), data.pop_back(), i--;
}
template<class T> array<T, 4> make_array(T a, T b, T c, T d) { array<T,4> x; x[0] = a; x[1] = b; x[2] = c; x[3] = d; return x; }
template<class T> array<T, 3> make_array(T a, T b, T c) { array<T,3> x; x[0] = a; x[1] = b; x[2] = c; return x; }
template<class T> array<T, 2> make_array(T a, T b) { array<T,2> x; x[0] = a; x[1] = b; return x; }
template<class T> constexpr array<T, 4> make_array(T a, T b, T c, T d) { return array<T,4>{a,b,c,d}; }
template<class T> constexpr array<T, 3> make_array(T a, T b, T c) { return array<T,3>{a,b,c}; }
template<class T> constexpr array<T, 2> make_array(T a, T b) { return array<T,2>{a,b}; }
// Find in a std::map or std::unordered_map, or return null.
template<class Map, class Key>
@@ -934,7 +934,7 @@ template<class T> ld binsearch(ld dmin, ld dmax, const T& f, int iterations = 20
return dmin;
}
static const int max_vec = (1<<14);
static constexpr int max_vec = (1<<14);
extern bool needConfirmationEvenIfSaved();
typedef unsigned long long flagtype;