diff --git a/Makefile b/Makefile index d74aade6..5f36d265 100644 --- a/Makefile +++ b/Makefile @@ -83,7 +83,7 @@ ifeq (${TOOLCHAIN},clang) CXXFLAGS_STD = -std=c++11 CXXFLAGS_EARLY += -march=native -fPIC CXXFLAGS_EARLY += -W -Wall -Wextra -Werror -pedantic - CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-unknown-warning-option + CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-unknown-warning-option -Wno-overloaded-virtual endif ifeq (${TOOLCHAIN},gcc) diff --git a/config.cpp b/config.cpp index f91e60dd..993629d4 100644 --- a/config.cpp +++ b/config.cpp @@ -27,9 +27,9 @@ struct supersaver { virtual void load(const string& s) = 0; virtual bool dosave() = 0; virtual void reset() = 0; - virtual ~supersaver() {} virtual bool affects(void* v) { return false; } virtual void set_default() = 0; + virtual ~supersaver() = default; }; typedef vector> saverlist; @@ -56,7 +56,7 @@ struct setting { return parameter_name + "|" + config_name + "|" + menu_item_name + "|" + help_text; } virtual cld get_cld() = 0; - setting() { restrict = auto_restrict; is_editable = false; } + explicit setting() { restrict = auto_restrict; is_editable = false; } virtual void check_change() { cld val = get_cld(); if(val != last_value) { @@ -68,7 +68,7 @@ struct setting { setting *set_sets(const reaction_t& s) { sets = s; return this; } setting *set_extra(const reaction_t& r); setting *set_reaction(const reaction_t& r); - virtual ~setting() {} + virtual ~setting() = default; virtual void load_from(const string& s) { println(hlog, "cannot load this parameter"); exit(1); @@ -100,7 +100,7 @@ struct list_setting : setting { default_key = key; return this; } - virtual void show_edit_option(char key) override; + void show_edit_option(char key) override; }; template struct enum_setting : list_setting { @@ -108,10 +108,10 @@ template struct enum_setting : list_setting { T dft; int get_value() override { return (int) *value; } void set_value(int i) override { *value = (T) i; } - virtual bool affects(void* v) override { return v == value; } - virtual void add_as_saver() override; - virtual cld get_cld() override { return get_value(); } - virtual void load_from(const string& s) override { + bool affects(void* v) override { return v == value; } + void add_as_saver() override; + cld get_cld() override { return get_value(); } + void load_from(const string& s) override { *value = (T) parseint(s); } }; @@ -134,11 +134,10 @@ struct float_setting : public setting { function modify_me; float_setting *modif(const function& r) { modify_me = r; return this; } void add_as_saver() override; - virtual bool affects(void *v) override { return v == value; } - virtual void show_edit_option(char key) override; - virtual cld get_cld() override { return *value; } - - virtual void load_from(const string& s) override; + bool affects(void *v) override { return v == value; } + void show_edit_option(char key) override; + cld get_cld() override { return *value; } + void load_from(const string& s) override; }; struct int_setting : public setting { @@ -149,9 +148,9 @@ struct int_setting : public setting { void add_as_saver() override; function modify_me; int_setting *modif(const function& r) { modify_me = r; return this; } - virtual bool affects(void *v) override { return v == value; } - virtual void show_edit_option(char key) override; - virtual cld get_cld() override { return *value; } + bool affects(void *v) override { return v == value; } + void show_edit_option(char key) override; + cld get_cld() override { return *value; } int_setting *editable(int min_value, int max_value, ld step, string menu_item_name, string help_text, char key) { this->min_value = min_value; this->max_value = max_value; @@ -162,7 +161,7 @@ struct int_setting : public setting { return this; } - virtual void load_from(const string& s) override { + void load_from(const string& s) override { *value = parseint(s); } }; @@ -176,10 +175,10 @@ struct bool_setting : public setting { is_editable = true; menu_item_name = cap; default_key = key; return this; } - virtual bool affects(void *v) override { return v == value; } - virtual void show_edit_option(char key) override; - virtual cld get_cld() override { return *value ? 1 : 0; } - virtual void load_from(const string& s) override { + bool affects(void *v) override { return v == value; } + void show_edit_option(char key) override; + cld get_cld() override { return *value ? 1 : 0; } + void load_from(const string& s) override { *value = parseint(s); } }; @@ -188,9 +187,9 @@ struct custom_setting : public setting { function custom_viewer; function custom_value; function custom_affect; - virtual void show_edit_option(char key) override { custom_viewer(key); } - virtual cld get_cld() override { return custom_value(); } - virtual bool affects(void *v) override { return custom_affect(v); } + void show_edit_option(char key) override { custom_viewer(key); } + cld get_cld() override { return custom_value(); } + bool affects(void *v) override { return custom_affect(v); } }; #if CAP_CONFIG @@ -198,11 +197,11 @@ struct custom_setting : public setting { template struct dsaver : supersaver { T& val; T dft; - bool dosave() { return val != dft; } - void reset() { val = dft; } - dsaver(T& val) : val(val) { } - bool affects(void* v) { return v == &val; } - void set_default() { dft = val; } + bool dosave() override { return val != dft; } + void reset() override { val = dft; } + explicit dsaver(T& val) : val(val) { } + bool affects(void* v) override { return v == &val; } + void set_default() override { dft = val; } }; template struct saver : dsaver {}; @@ -233,13 +232,13 @@ template void set_saver_default(T& val) { template struct saverenum : supersaver { T& val; T dft; - bool dosave() { return val != dft; } - void reset() { val = dft; } - saverenum(T& v) : val(v) { } - string save() { return its(int(val)); } - void load(const string& s) { val = (T) atoi(s.c_str()); } - virtual bool affects(void* v) { return v == &val; } - virtual void set_default() { dft = val; } + explicit saverenum(T& v) : val(v) { } + bool dosave() override { return val != dft; } + void reset() override { val = dft; } + string save() override { return its(int(val)); } + void load(const string& s) override { val = (T) atoi(s.c_str()); } + bool affects(void* v) override { return v == &val; } + void set_default() override { dft = val; } }; template void addsaverenum(T& i, U name, T dft) { @@ -254,39 +253,39 @@ template void addsaverenum(T& i, U name) { } template<> struct saver : dsaver { - saver(int& val) : dsaver(val) { } - string save() { return its(val); } - void load(const string& s) { val = atoi(s.c_str()); } + explicit saver(int& val) : dsaver(val) { } + string save() override { return its(val); } + void load(const string& s) override { val = atoi(s.c_str()); } }; template<> struct saver : dsaver { - saver(char& val) : dsaver(val) { } - string save() { return its(val); } - void load(const string& s) { val = atoi(s.c_str()); } + explicit saver(char& val) : dsaver(val) { } + string save() override { return its(val); } + void load(const string& s) override { val = atoi(s.c_str()); } }; template<> struct saver : dsaver { - saver(bool& val) : dsaver(val) { } - string save() { return val ? "yes" : "no"; } - void load(const string& s) { val = isize(s) && s[0] == 'y'; } + explicit saver(bool& val) : dsaver(val) { } + string save() override { return val ? "yes" : "no"; } + void load(const string& s) override { val = isize(s) && s[0] == 'y'; } }; template<> struct saver : dsaver { - saver(unsigned& val) : dsaver(val) { } - string save() { return itsh(val); } - void load(const string& s) { val = (unsigned) strtoll(s.c_str(), NULL, 16); } + explicit saver(unsigned& val) : dsaver(val) { } + string save() override { return itsh(val); } + void load(const string& s) override { val = (unsigned) strtoll(s.c_str(), NULL, 16); } }; template<> struct saver : dsaver { - saver(string& val) : dsaver(val) { } - string save() { return val; } - void load(const string& s) { val = s; } + explicit saver(string& val) : dsaver(val) { } + string save() override { return val; } + void load(const string& s) override { val = s; } }; template<> struct saver : dsaver { - saver(ld& val) : dsaver(val) { } - string save() { return fts(val, 10); } - void load(const string& s) { + explicit saver(ld& val) : dsaver(val) { } + string save() override { return fts(val, 10); } + void load(const string& s) override { if(s == "0.0000000000e+000") ; // ignore! else val = atof(s.c_str()); } diff --git a/drawing.cpp b/drawing.cpp index a1fb5b77..08e6b60a 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -56,7 +56,7 @@ struct drawqueueitem { virtual void draw() = 0; /** \brief Draw the object as background. */ virtual void draw_back() {} - virtual ~drawqueueitem() {} + virtual ~drawqueueitem() = default; /** \brief When minimizing OpenGL calls, we need to group items of the same color, etc. together. This value is used as an extra sorting key. */ virtual color_t outline_group() = 0; }; @@ -85,12 +85,12 @@ struct dqi_poly : drawqueueitem { hyperpoint intester; /** \brief temporarily cached data */ float cache; - void draw(); + void draw() override; #if CAP_GL void gldraw(); #endif - void draw_back(); - virtual color_t outline_group() { return outline; } + void draw_back() override; + color_t outline_group() override { return outline; } }; /** \brief Drawqueueitem used to draw lines */ @@ -101,9 +101,9 @@ struct dqi_line : drawqueueitem { int prf; /** \brief width of this line */ double width; - void draw(); - void draw_back(); - virtual color_t outline_group() { return color; } + void draw() override; + void draw_back() override; + color_t outline_group() override { return color; } }; /** \brief Drawqueueitem used to draw strings, using sccreen coodinates */ @@ -120,8 +120,8 @@ struct dqi_string : drawqueueitem { int frame; /** alignment (0-8-16) */ int align; - void draw(); - virtual color_t outline_group() { return 1; } + void draw() override; + color_t outline_group() override { return 1; } }; /** Drawqueueitem used to draw circles, using screen coordinates */ @@ -134,16 +134,16 @@ struct dqi_circle : drawqueueitem { color_t fillcolor; /** \brief width of the circle */ double linewidth; - void draw(); - virtual color_t outline_group() { return 2; } + void draw() override; + color_t outline_group() override { return 2; } }; /** \brief Perform an arbitrary action. May temporarily change the model, etc. */ struct dqi_action : drawqueueitem { reaction_t action; - dqi_action(const reaction_t& a) : action(a) {} - void draw() { action(); } - virtual color_t outline_group() { return 2; } + explicit dqi_action(const reaction_t& a) : action(a) {} + void draw() override { action(); } + color_t outline_group() override { return 2; } }; #endif diff --git a/hprint.cpp b/hprint.cpp index 6fcb5982..f3d1e1ff 100644 --- a/hprint.cpp +++ b/hprint.cpp @@ -122,25 +122,25 @@ struct hstream_exception : hr_exception { hstream_exception() {} }; struct fhstream : hstream { color_t vernum; - virtual color_t get_vernum() override { return vernum; } FILE *f; - virtual void write_char(char c) override { write_chars(&c, 1); } - virtual void write_chars(const char* c, size_t i) override { if(fwrite(c, i, 1, f) != 1) throw hstream_exception(); } - virtual void read_chars(char* c, size_t i) override { if(fread(c, i, 1, f) != 1) throw hstream_exception(); } - virtual char read_char() override { char c; read_chars(&c, 1); return c; } - fhstream() { f = NULL; vernum = VERNUM_HEX; } - fhstream(const string pathname, const char *mode) { f = fopen(pathname.c_str(), mode); vernum = VERNUM_HEX; } + explicit fhstream() { f = NULL; vernum = VERNUM_HEX; } + explicit fhstream(const string pathname, const char *mode) { f = fopen(pathname.c_str(), mode); vernum = VERNUM_HEX; } ~fhstream() { if(f) fclose(f); } + color_t get_vernum() override { return vernum; } + void write_char(char c) override { write_chars(&c, 1); } + void write_chars(const char* c, size_t i) override { if(fwrite(c, i, 1, f) != 1) throw hstream_exception(); } + void read_chars(char* c, size_t i) override { if(fread(c, i, 1, f) != 1) throw hstream_exception(); } + char read_char() override { char c; read_chars(&c, 1); return c; } }; struct shstream : hstream { color_t vernum; - virtual color_t get_vernum() override { return vernum; } string s; int pos; - shstream(const string& t = "") : s(t) { pos = 0; vernum = VERNUM_HEX; } - virtual void write_char(char c) override { s += c; } - virtual char read_char() override { if(pos == isize(s)) throw hstream_exception(); return s[pos++]; } + explicit shstream(const string& t = "") : s(t) { pos = 0; vernum = VERNUM_HEX; } + color_t get_vernum() override { return vernum; } + void write_char(char c) override { s += c; } + char read_char() override { if(pos == isize(s)) throw hstream_exception(); return s[pos++]; } }; inline void print(hstream& hs) {} @@ -243,11 +243,11 @@ int SDL_GetTicks(); struct logger : hstream { int indentation; bool doindent; - logger() { doindent = false; } - virtual void write_char(char c) { if(doindent) { doindent = false; + explicit logger() { doindent = false; } + void write_char(char c) override { if(doindent) { doindent = false; if(debugflags & DF_TIME) { int t = SDL_GetTicks(); if(t < 0) t = 999999; t %= 1000000; string s = its(t); while(isize(s) < 6) s = "0" + s; for(char c: s) special_log(c); special_log(' '); } for(int i=0; i ind; - indenter(int i = 2) : ind(hlog.indentation, hlog.indentation + (i)) {} + explicit indenter(int i = 2) : ind(hlog.indentation, hlog.indentation + (i)) {} }; struct indenter_finish : indenter { - indenter_finish(bool b = true): indenter(b ? 2:0) {} + explicit indenter_finish(bool b = true): indenter(b ? 2:0) {} ~indenter_finish() { if(hlog.indentation != ind.backup) println(hlog, "(done)"); } }; diff --git a/hyper_function.h b/hyper_function.h index 5bb8a040..9904010a 100644 --- a/hyper_function.h +++ b/hyper_function.h @@ -19,10 +19,10 @@ template struct function_state : function_state_base { T t_; explicit function_state(T t) : t_(std::move(t)) {} - R call(Args... args) const /*override*/ { + R call(Args... args) const override { return const_cast(t_)(static_cast(args)...); } - function_state_base *clone() const /*override*/ { + function_state_base *clone() const override { return new function_state(*this); } }; diff --git a/inforder.cpp b/inforder.cpp index 4abe524f..a32094d2 100644 --- a/inforder.cpp +++ b/inforder.cpp @@ -21,7 +21,7 @@ EX namespace inforder { struct hrmap_inforder : hrmap_hyperbolic { - heptagon *create_step(heptagon *h, int direction) { + heptagon *create_step(heptagon *h, int direction) override { int deg = h->type; if(mixed()) deg = 7 - deg; auto h1 = init_heptagon(deg); @@ -51,4 +51,4 @@ EX namespace inforder { EX } -} \ No newline at end of file +} diff --git a/kite.cpp b/kite.cpp index 0f3dc6da..14d1531c 100644 --- a/kite.cpp +++ b/kite.cpp @@ -339,7 +339,7 @@ struct hrmap_kite : hrmap { return gm * where; } - virtual int wall_offset(cell *c) { + int wall_offset(cell *c) override { if(WDIM == 3) return kite::getshape(c->master) == kite::pKite ? 10 : 0; else @@ -426,4 +426,4 @@ auto hooksw = addHook(hooks_swapdim, 100, [] { if(kite::in() && currentmap) kite #endif }} - \ No newline at end of file + diff --git a/pattern2.cpp b/pattern2.cpp index efd83536..ae257c6d 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -664,10 +664,10 @@ EX namespace patterns { si.reflect = false; } else { - int ids = 0, tids = 0, td = 0; + int ids = 0, td = 0; for(int i=0; imove(2*i)->master->fieldval; - ids |= (1<move(2*i)->master->fieldval; diff --git a/quotient.cpp b/quotient.cpp index d4020bc7..4a7428d4 100644 --- a/quotient.cpp +++ b/quotient.cpp @@ -64,16 +64,16 @@ struct hrmap_quotient : hrmap_standard { void build(); - hrmap_quotient() { + explicit hrmap_quotient() { generate_connections(); build(); } - hrmap_quotient(const vector& con) : connections(con) { + explicit hrmap_quotient(const vector& con) : connections(con) { build(); } - heptagon *getOrigin() { return allh[0]; } + heptagon *getOrigin() override { return allh[0]; } ~hrmap_quotient() { for(int i=0; i& allcells() { return celllist; } + vector& allcells() override { return celllist; } }; #endif diff --git a/reg3.cpp b/reg3.cpp index ddcc2559..37859474 100644 --- a/reg3.cpp +++ b/reg3.cpp @@ -649,7 +649,7 @@ EX namespace reg3 { int h_id; /** transition matrix to that heptagon */ transmatrix T; - /** the sequence of moves we need to make to get there */; + /** the sequence of moves we need to make to get there */ vector move_sequence; }; @@ -680,7 +680,7 @@ EX namespace reg3 { return cgi.subshapes[id].vertices_only_local; } - transmatrix master_relative(cell *c, bool get_inverse) { + transmatrix master_relative(cell *c, bool get_inverse) override { int id = local_id.at(c).second; auto& ss = cgi.subshapes[id]; return get_inverse ? ss.from_cellcenter : ss.to_cellcenter; @@ -689,11 +689,11 @@ EX namespace reg3 { void make_subconnections(); int wall_offset(cell *c) override; - int shvid(cell *c) { return local_id.at(c).second; } + int shvid(cell *c) override { return local_id.at(c).second; } - virtual transmatrix ray_iadj(cell *c, int i) override; + transmatrix ray_iadj(cell *c, int i) override; - const vector& adjacent_dirs(cell *c, int i) { + const vector& adjacent_dirs(cell *c, int i) override { int id = local_id.at(c).second; return cgi.subshapes[id].dirs_adjacent[i]; } @@ -1490,7 +1490,7 @@ EX namespace reg3 { return cgi.vertices_only; } - const vector& adjacent_dirs(cell *c, int i) { + const vector& adjacent_dirs(cell *c, int i) override { return cgi.dirs_adjacent[i]; } @@ -1582,7 +1582,7 @@ EX namespace reg3 { clearfrom(allh[0]); } - virtual struct transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + struct transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { return iso_inverse(locations[h1->fieldval]) * locations[h2->fieldval]; } @@ -1901,13 +1901,13 @@ EX namespace reg3 { return relative_matrix_via_masters(c2, c1, hint); } - transmatrix master_relative(cell *c, bool get_inverse) { + transmatrix master_relative(cell *c, bool get_inverse) override { if(PURE) return Id; int aid = cell_id.at(c); return quotient_map->master_relative(quotient_map->acells[aid], get_inverse); } - int shvid(cell *c) { + int shvid(cell *c) override { if(PURE) return 0; if(!cell_id.count(c)) return quotient_map->shvid(c); int aid = cell_id.at(c); @@ -1963,14 +1963,14 @@ EX namespace reg3 { c->c.connect(d, c1, ac->c.spin(d), false); } - virtual transmatrix ray_iadj(cell *c, int i) { + transmatrix ray_iadj(cell *c, int i) override { if(PURE) return iadj(c, i); if(!cell_id.count(c)) return quotient_map->ray_iadj(c, i); /* necessary because ray samples are from quotient_map */ int aid = cell_id.at(c); return quotient_map->ray_iadj(quotient_map->acells[aid], i); } - const vector& adjacent_dirs(cell *c, int i) { + const vector& adjacent_dirs(cell *c, int i) override { if(PURE) return cgi.dirs_adjacent[i]; int aid = cell_id.at(c); return quotient_map->adjacent_dirs(quotient_map->acells[aid], i); diff --git a/sky.cpp b/sky.cpp index 80f6897a..ea7f8c50 100644 --- a/sky.cpp +++ b/sky.cpp @@ -24,11 +24,11 @@ struct sky_item { struct dqi_sky : drawqueueitem { vector sky; - void draw(); - virtual color_t outline_group() { return 3; } + void draw() override; + color_t outline_group() override { return 3; } // singleton - dqi_sky() { hr::sky = this; } - ~dqi_sky() { hr::sky = NULL; } + explicit dqi_sky() { hr::sky = this; } + ~dqi_sky() override { hr::sky = NULL; } }; EX struct dqi_sky *sky; diff --git a/sphere.cpp b/sphere.cpp index 8d254ec6..7ed5a9c1 100644 --- a/sphere.cpp +++ b/sphere.cpp @@ -139,14 +139,14 @@ struct hrmap_spherical : hrmap_standard { #endif } - heptagon *getOrigin() { return dodecahedron[0]; } + heptagon *getOrigin() override { return dodecahedron[0]; } ~hrmap_spherical() { for(int i=0; i