1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-18 07:27:40 +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

View File

@@ -197,10 +197,10 @@ template<class T> void tailored_delete(T* x) {
delete[] ((char*) (x));
}
static const struct wstep_t { wstep_t() {} } wstep;
static const struct wmirror_t { wmirror_t() {}} wmirror;
static const struct rev_t { rev_t() {} } rev;
static const struct revstep_t { revstep_t() {}} revstep;
static constexpr struct wstep_t {} wstep;
static constexpr struct wmirror_t {} wmirror;
static constexpr struct rev_t {} rev;
static constexpr struct revstep_t {} revstep;
extern int hrand(int);
@@ -286,7 +286,7 @@ enum hstate { hsOrigin, hsA, hsB, hsError, hsA0, hsA1, hsB0, hsB1, hsC };
struct cell *createMov(struct cell *c, int d);
struct heptagon *createStep(struct heptagon *c, int d);
struct cdata_or_heptagon { virtual ~cdata_or_heptagon() {} };
struct cdata_or_heptagon { virtual ~cdata_or_heptagon() = default; };
struct cdata : cdata_or_heptagon {
int val[4];
@@ -452,7 +452,7 @@ struct celllister : manual_celllister {
};
/** \brief translate heptspins to cellwalkers and vice versa */
static const struct cth_t { cth_t() {}} cth;
static constexpr struct cth_t {} cth;
inline heptspin operator+ (cellwalker cw, cth_t) { return heptspin(cw.at->master, cw.spin * DUALMUL, cw.mirrored); }
inline cellwalker operator+ (heptspin hs, cth_t) { return cellwalker(hs.at->c7, hs.spin / DUALMUL, hs.mirrored); }