From: Richard Kreckel Date: Thu, 26 Nov 2015 11:20:20 +0000 (+0100) Subject: Make ample use of the contextual keyword 'override'. X-Git-Tag: release_1-7-0~7^2~45 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=d5b86dd10dd9cba12175d07af0b6edfc9a215e36 Make ample use of the contextual keyword 'override'. This patch adds the C++11 contextual keyword 'override' to every overridden virtual function declaration except where that would incur macro duplications. Along the way, it fixes some comments about member functions 'virtuality'. --- diff --git a/check/time_antipode.cpp b/check/time_antipode.cpp index 02ebaf1b..9c64fbc2 100644 --- a/check/time_antipode.cpp +++ b/check/time_antipode.cpp @@ -105,9 +105,9 @@ protected: class Sigma : public vertex { public: Sigma(ijpair ij = ijpair(0,0)) : vertex(ij) { } - vertex* copy() const { return new Sigma(*this); } - ijpair get_increment() const { return ijpair(indices.first+indices.second+1, 0); } - const ex evaluate(const symbol &x, const unsigned grad) const; + vertex* copy() const override { return new Sigma(*this); } + ijpair get_increment() const override { return ijpair(indices.first+indices.second+1, 0); } + const ex evaluate(const symbol &x, const unsigned grad) const override; private: }; @@ -137,9 +137,9 @@ const ex Sigma::evaluate(const symbol &x, const unsigned grad) const class Sigma_flipped : public Sigma { public: Sigma_flipped(ijpair ij = ijpair(0,0)) : Sigma(ij) { } - vertex* copy() const { return new Sigma_flipped(*this); } - ijpair get_increment() const { return ijpair(0, indices.first+indices.second+1); } - const ex evaluate(const symbol &x, const unsigned grad) const { return Sigma::evaluate(x, grad); } + vertex* copy() const override { return new Sigma_flipped(*this); } + ijpair get_increment() const override { return ijpair(0, indices.first+indices.second+1); } + const ex evaluate(const symbol &x, const unsigned grad) const override { return Sigma::evaluate(x, grad); } private: }; @@ -150,9 +150,9 @@ private: class Gamma : public vertex { public: Gamma(ijpair ij = ijpair(0,0)) : vertex(ij) { } - vertex* copy() const { return new Gamma(*this); } - ijpair get_increment() const { return ijpair(indices.first+indices.second+1, 0); } - const ex evaluate(const symbol &x, const unsigned grad) const; + vertex* copy() const override { return new Gamma(*this); } + ijpair get_increment() const override { return ijpair(indices.first+indices.second+1, 0); } + const ex evaluate(const symbol &x, const unsigned grad) const override; private: }; @@ -184,9 +184,9 @@ const ex Gamma::evaluate(const symbol &x, const unsigned grad) const class Vacuum : public vertex { public: Vacuum(ijpair ij = ijpair(0,0)) : vertex(ij) { } - vertex* copy() const { return new Vacuum(*this); } - ijpair get_increment() const { return ijpair(0, indices.first+indices.second+1); } - const ex evaluate(const symbol &x, const unsigned grad) const; + vertex* copy() const override { return new Vacuum(*this); } + ijpair get_increment() const override { return ijpair(0, indices.first+indices.second+1); } + const ex evaluate(const symbol &x, const unsigned grad) const override; private: }; diff --git a/check/time_uvar_gcd.cpp b/check/time_uvar_gcd.cpp index 11fbe1ec..405e8207 100644 --- a/check/time_uvar_gcd.cpp +++ b/check/time_uvar_gcd.cpp @@ -1616,7 +1616,7 @@ static const std::string r2_srep_3("\ class sym_finder : public visitor, public symbol::visitor { protected: - inline void visit(const symbol& s) + inline void visit(const symbol& s) override { found.insert(s); } diff --git a/doc/examples/mystring.cpp b/doc/examples/mystring.cpp index b86f18b9..bcbf96a8 100644 --- a/doc/examples/mystring.cpp +++ b/doc/examples/mystring.cpp @@ -14,7 +14,7 @@ class mystring : public basic GINAC_DECLARE_REGISTERED_CLASS(mystring, basic) public: mystring(const string &s); - ex eval(int level) const; + ex eval(int level) const override; private: string str; diff --git a/ginac/add.h b/ginac/add.h index db9bda9d..659692b9 100644 --- a/ginac/add.h +++ b/ginac/add.h @@ -45,37 +45,37 @@ public: // functions overriding virtual functions from base classes public: - unsigned precedence() const {return 40;} - bool info(unsigned inf) const; - bool is_polynomial(const ex & var) const; - int degree(const ex & s) const; - int ldegree(const ex & s) const; - ex coeff(const ex & s, int n=1) const; - ex eval(int level=0) const; - ex evalm() const; - ex series(const relational & r, int order, unsigned options = 0) const; - ex normal(exmap & repl, exmap & rev_lookup, int level=0) const; - numeric integer_content() const; - ex smod(const numeric &xi) const; - numeric max_coefficient() const; - ex conjugate() const; - ex real_part() const; - ex imag_part() const; - exvector get_free_indices() const; - ex eval_ncmul(const exvector & v) const; + unsigned precedence() const override {return 40;} + bool info(unsigned inf) const override; + bool is_polynomial(const ex & var) const override; + int degree(const ex & s) const override; + int ldegree(const ex & s) const override; + ex coeff(const ex & s, int n=1) const override; + ex eval(int level=0) const override; + ex evalm() const override; + ex series(const relational & r, int order, unsigned options = 0) const override; + ex normal(exmap & repl, exmap & rev_lookup, int level=0) const override; + numeric integer_content() const override; + ex smod(const numeric &xi) const override; + numeric max_coefficient() const override; + ex conjugate() const override; + ex real_part() const override; + ex imag_part() const override; + exvector get_free_indices() const override; + ex eval_ncmul(const exvector & v) const override; protected: - ex derivative(const symbol & s) const; - unsigned return_type() const; - return_type_t return_type_tinfo() const; - ex thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming = false) const; - ex thisexpairseq(epvector && vp, const ex & oc, bool do_index_renaming = false) const; - expair split_ex_to_pair(const ex & e) const; + ex derivative(const symbol & s) const override; + unsigned return_type() const override; + return_type_t return_type_tinfo() const override; + ex thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming = false) const override; + ex thisexpairseq(epvector && vp, const ex & oc, bool do_index_renaming = false) const override; + expair split_ex_to_pair(const ex & e) const override; expair combine_ex_with_coeff_to_pair(const ex & e, - const ex & c) const; + const ex & c) const override; expair combine_pair_with_coeff_to_pair(const expair & p, - const ex & c) const; - ex recombine_pair_to_ex(const expair & p) const; - ex expand(unsigned options=0) const; + const ex & c) const override; + ex recombine_pair_to_ex(const expair & p) const override; + ex expand(unsigned options=0) const override; // non-virtual functions in this class protected: diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 59cd08f3..01d36971 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -421,7 +421,7 @@ ex basic::eval(int level) const struct evalf_map_function : public map_function { int level; evalf_map_function(int l) : level(l) {} - ex operator()(const ex & e) { return evalf(e, level); } + ex operator()(const ex & e) override { return evalf(e, level); } }; /** Evaluate object numerically. */ @@ -443,7 +443,7 @@ ex basic::evalf(int level) const /** Function object to be applied by basic::evalm(). */ struct evalm_map_function : public map_function { - ex operator()(const ex & e) { return evalm(e); } + ex operator()(const ex & e) override { return evalm(e); } } map_evalm; /** Evaluate sums, products and integer powers of matrices. */ @@ -457,7 +457,7 @@ ex basic::evalm() const /** Function object to be applied by basic::eval_integ(). */ struct eval_integ_map_function : public map_function { - ex operator()(const ex & e) { return eval_integ(e); } + ex operator()(const ex & e) override { return eval_integ(e); } } map_eval_integ; /** Evaluate integrals, if result is known. */ @@ -703,7 +703,7 @@ ex basic::eval_ncmul(const exvector & v) const struct derivative_map_function : public map_function { const symbol &s; derivative_map_function(const symbol &sym) : s(sym) {} - ex operator()(const ex & e) { return diff(e, s); } + ex operator()(const ex & e) override { return diff(e, s); } }; /** Default implementation of ex::diff(). It maps the operation on the @@ -797,7 +797,7 @@ unsigned basic::calchash() const struct expand_map_function : public map_function { unsigned options; expand_map_function(unsigned o) : options(o) {} - ex operator()(const ex & e) { return e.expand(options); } + ex operator()(const ex & e) override { return e.expand(options); } }; /** Expand expression, i.e. multiply it out and return the result as a new diff --git a/ginac/clifford.h b/ginac/clifford.h index 6af79dbc..0193fdaf 100644 --- a/ginac/clifford.h +++ b/ginac/clifford.h @@ -51,16 +51,16 @@ public: // functions overriding virtual functions from base classes public: - unsigned precedence() const { return 65; } - void archive(archive_node& n) const; - void read_archive(const archive_node& n, lst& sym_lst); + unsigned precedence() const override { return 65; } + void archive(archive_node& n) const override; + void read_archive(const archive_node& n, lst& sym_lst) override; protected: - ex eval_ncmul(const exvector & v) const; - bool match_same_type(const basic & other) const; - ex thiscontainer(const exvector & v) const; - ex thiscontainer(exvector && v) const; - unsigned return_type() const { return return_types::noncommutative; } - return_type_t return_type_tinfo() const; + ex eval_ncmul(const exvector & v) const override; + bool match_same_type(const basic & other) const override; + ex thiscontainer(const exvector & v) const override; + ex thiscontainer(exvector && v) const override; + unsigned return_type() const override { return return_types::noncommutative; } + return_type_t return_type_tinfo() const override; // non-virtual functions in this class public: unsigned char get_representation_label() const { return representation_label; } @@ -69,10 +69,10 @@ public: bool same_metric(const ex & other) const; int get_commutator_sign() const { return commutator_sign; } //**< See the member variable commutator_sign */ - inline size_t nops() const {return inherited::nops() + 1; } - ex op(size_t i) const; - ex & let_op(size_t i); - ex subs(const exmap & m, unsigned options = 0) const; + inline size_t nops() const override {return inherited::nops() + 1; } + ex op(size_t i) const override; + ex & let_op(size_t i) override; + ex subs(const exmap & m, unsigned options = 0) const override; protected: void do_print_dflt(const print_dflt & c, unsigned level) const; @@ -106,7 +106,7 @@ class cliffordunit : public tensor // functions overriding virtual functions from base classes public: - bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const; + bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override; // non-virtual functions in this class protected: @@ -123,7 +123,7 @@ class diracgamma : public cliffordunit // functions overriding virtual functions from base classes public: - bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const; + bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override; // non-virtual functions in this class protected: @@ -140,7 +140,7 @@ class diracgamma5 : public tensor GINAC_DECLARE_REGISTERED_CLASS(diracgamma5, tensor) // functions overriding virtual functions from base classes - ex conjugate() const; + ex conjugate() const override; // non-virtual functions in this class protected: @@ -157,7 +157,7 @@ class diracgammaL : public tensor GINAC_DECLARE_REGISTERED_CLASS(diracgammaL, tensor) // functions overriding virtual functions from base classes - ex conjugate() const; + ex conjugate() const override; // non-virtual functions in this class protected: @@ -174,7 +174,7 @@ class diracgammaR : public tensor GINAC_DECLARE_REGISTERED_CLASS(diracgammaR, tensor) // functions overriding virtual functions from base classes - ex conjugate() const; + ex conjugate() const override; // non-virtual functions in this class protected: diff --git a/ginac/color.h b/ginac/color.h index 460e7a9d..448a81ed 100644 --- a/ginac/color.h +++ b/ginac/color.h @@ -48,17 +48,17 @@ public: // internal constructors color(unsigned char rl, const exvector & v); color(unsigned char rl, exvector && v); - void archive(archive_node& n) const; - void read_archive(const archive_node& n, lst& sym_lst); + void archive(archive_node& n) const override; + void read_archive(const archive_node& n, lst& sym_lst) override; // functions overriding virtual functions from base classes protected: - ex eval_ncmul(const exvector & v) const; - bool match_same_type(const basic & other) const; - ex thiscontainer(const exvector & v) const; - ex thiscontainer(exvector && v) const; - unsigned return_type() const { return return_types::noncommutative; } - return_type_t return_type_tinfo() const; + ex eval_ncmul(const exvector & v) const override; + bool match_same_type(const basic & other) const override; + ex thiscontainer(const exvector & v) const override; + ex thiscontainer(exvector && v) const override; + unsigned return_type() const override { return return_types::noncommutative; } + return_type_t return_type_tinfo() const override; // non-virtual functions in this class public: @@ -90,7 +90,7 @@ class su3t : public tensor // functions overriding virtual functions from base classes public: - bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const; + bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override; // non-virtual functions in this class protected: @@ -107,12 +107,13 @@ class su3f : public tensor // functions overriding virtual functions from base classes public: - ex eval_indexed(const basic & i) const; - bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const; + ex eval_indexed(const basic & i) const override; + bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override; +protected: + unsigned return_type() const override { return return_types::commutative; } // non-virtual functions in this class protected: - unsigned return_type() const { return return_types::commutative; } void do_print(const print_context & c, unsigned level) const; void do_print_latex(const print_latex & c, unsigned level) const; }; @@ -125,12 +126,13 @@ class su3d : public tensor // functions overriding virtual functions from base classes public: - ex eval_indexed(const basic & i) const; - bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const; + ex eval_indexed(const basic & i) const override; + bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override; +protected: + unsigned return_type() const override { return return_types::commutative; } // non-virtual functions in this class protected: - unsigned return_type() const { return return_types::commutative; } void do_print(const print_context & c, unsigned level) const; void do_print_latex(const print_latex & c, unsigned level) const; }; diff --git a/ginac/constant.h b/ginac/constant.h index f75a629f..430c87ff 100644 --- a/ginac/constant.h +++ b/ginac/constant.h @@ -47,18 +47,18 @@ public: // functions overriding virtual functions from base classes public: - bool info(unsigned inf) const; - ex evalf(int level = 0) const; - bool is_polynomial(const ex & var) const; - ex conjugate() const; - ex real_part() const; - ex imag_part() const; - void archive(archive_node& n) const; - void read_archive(const archive_node& n, lst& syms); + bool info(unsigned inf) const override; + ex evalf(int level = 0) const override; + bool is_polynomial(const ex & var) const override; + ex conjugate() const override; + ex real_part() const override; + ex imag_part() const override; + void archive(archive_node& n) const override; + void read_archive(const archive_node& n, lst& syms) override; protected: - ex derivative(const symbol & s) const; - bool is_equal_same_type(const basic & other) const; - unsigned calchash() const; + ex derivative(const symbol & s) const override; + bool is_equal_same_type(const basic & other) const override; + unsigned calchash() const override; // non-virtual functions in this class protected: diff --git a/ginac/container.h b/ginac/container.h index 5ba09434..dd8be131 100644 --- a/ginac/container.h +++ b/ginac/container.h @@ -352,15 +352,15 @@ public: // functions overriding virtual functions from base classes public: - bool info(unsigned inf) const { return inherited::info(inf); } - unsigned precedence() const { return 10; } - size_t nops() const { return this->seq.size(); } - ex op(size_t i) const; - ex & let_op(size_t i); - ex eval(int level = 0) const; - ex subs(const exmap & m, unsigned options = 0) const; + bool info(unsigned inf) const override { return inherited::info(inf); } + unsigned precedence() const override { return 10; } + size_t nops() const override { return this->seq.size(); } + ex op(size_t i) const override; + ex & let_op(size_t i) override; + ex eval(int level = 0) const override; + ex subs(const exmap & m, unsigned options = 0) const override; - void read_archive(const archive_node &n, lst &sym_lst) + void read_archive(const archive_node &n, lst &sym_lst) override { inherited::read_archive(n, sym_lst); setflag(get_default_flags()); @@ -377,7 +377,7 @@ public: } /** Archive the object. */ - void archive(archive_node &n) const + void archive(archive_node &n) const override { inherited::archive(n); for (auto & i : this->seq) { @@ -386,7 +386,7 @@ public: } protected: - ex conjugate() const + ex conjugate() const override { STLT *newcont = nullptr; for (const_iterator i=this->seq.begin(); i!=this->seq.end(); ++i) { @@ -413,7 +413,7 @@ protected: return *this; } - ex real_part() const + ex real_part() const override { STLT cont; this->reserve(cont, nops()); @@ -424,7 +424,7 @@ protected: return thiscontainer(cont); } - ex imag_part() const + ex imag_part() const override { STLT cont; this->reserve(cont, nops()); @@ -435,7 +435,7 @@ protected: return thiscontainer(cont); } - bool is_equal_same_type(const basic & other) const; + bool is_equal_same_type(const basic & other) const override; // new virtual functions which can be overridden by derived classes protected: diff --git a/ginac/ex.h b/ginac/ex.h index 0e4d3754..343fa367 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -836,7 +836,7 @@ protected: ex (*ptr)(const ex &); public: explicit pointer_to_map_function(ex x(const ex &)) : ptr(x) {} - ex operator()(const ex & e) { return ptr(e); } + ex operator()(const ex & e) override { return ptr(e); } }; template @@ -846,7 +846,7 @@ protected: T1 arg1; public: explicit pointer_to_map_function_1arg(ex x(const ex &, T1), T1 a1) : ptr(x), arg1(a1) {} - ex operator()(const ex & e) { return ptr(e, arg1); } + ex operator()(const ex & e) override { return ptr(e, arg1); } }; template @@ -857,7 +857,7 @@ protected: T2 arg2; public: explicit pointer_to_map_function_2args(ex x(const ex &, T1, T2), T1 a1, T2 a2) : ptr(x), arg1(a1), arg2(a2) {} - ex operator()(const ex & e) { return ptr(e, arg1, arg2); } + ex operator()(const ex & e) override { return ptr(e, arg1, arg2); } }; template @@ -869,7 +869,7 @@ protected: T3 arg3; public: explicit pointer_to_map_function_3args(ex x(const ex &, T1, T2, T3), T1 a1, T2 a2, T3 a3) : ptr(x), arg1(a1), arg2(a2), arg3(a3) {} - ex operator()(const ex & e) { return ptr(e, arg1, arg2, arg3); } + ex operator()(const ex & e) override { return ptr(e, arg1, arg2, arg3); } }; template @@ -879,7 +879,7 @@ protected: C &c; public: explicit pointer_to_member_to_map_function(ex (C::*member)(const ex &), C &obj) : ptr(member), c(obj) {} - ex operator()(const ex & e) { return (c.*ptr)(e); } + ex operator()(const ex & e) override { return (c.*ptr)(e); } }; template @@ -890,7 +890,7 @@ protected: T1 arg1; public: explicit pointer_to_member_to_map_function_1arg(ex (C::*member)(const ex &, T1), C &obj, T1 a1) : ptr(member), c(obj), arg1(a1) {} - ex operator()(const ex & e) { return (c.*ptr)(e, arg1); } + ex operator()(const ex & e) override { return (c.*ptr)(e, arg1); } }; template @@ -902,7 +902,7 @@ protected: T2 arg2; public: explicit pointer_to_member_to_map_function_2args(ex (C::*member)(const ex&, T1, T2), C &obj, T1 a1, T2 a2) : ptr(member), c(obj), arg1(a1), arg2(a2) {} - ex operator()(const ex & e) { return (c.*ptr)(e, arg1, arg2); } + ex operator()(const ex & e) override { return (c.*ptr)(e, arg1, arg2); } }; template @@ -915,7 +915,7 @@ protected: T3 arg3; public: explicit pointer_to_member_to_map_function_3args(ex (C::*member)(const ex &, T1, T2, T3), C &obj, T1 a1, T2 a2, T3 a3) : ptr(member), c(obj), arg1(a1), arg2(a2), arg3(a3) {} - ex operator()(const ex & e) { return (c.*ptr)(e, arg1, arg2, arg3); } + ex operator()(const ex & e) override { return (c.*ptr)(e, arg1, arg2, arg3); } }; inline ex ex::map(ex f(const ex &)) const diff --git a/ginac/expairseq.h b/ginac/expairseq.h index 9f165726..d33ff332 100644 --- a/ginac/expairseq.h +++ b/ginac/expairseq.h @@ -59,25 +59,25 @@ public: // functions overriding virtual functions from base classes public: - unsigned precedence() const {return 10;} - bool info(unsigned inf) const; - size_t nops() const; - ex op(size_t i) const; - ex map(map_function & f) const; - ex eval(int level=0) const; - ex to_rational(exmap & repl) const; - ex to_polynomial(exmap & repl) const; - bool match(const ex & pattern, exmap& repl_lst) const; - ex subs(const exmap & m, unsigned options = 0) const; - ex conjugate() const; + unsigned precedence() const override {return 10;} + bool info(unsigned inf) const override; + size_t nops() const override; + ex op(size_t i) const override; + ex map(map_function & f) const override; + ex eval(int level=0) const override; + ex to_rational(exmap & repl) const override; + ex to_polynomial(exmap & repl) const override; + bool match(const ex & pattern, exmap& repl_lst) const override; + ex subs(const exmap & m, unsigned options = 0) const override; + ex conjugate() const override; - void archive(archive_node& n) const; - void read_archive(const archive_node& n, lst& syms); + void archive(archive_node& n) const override; + void read_archive(const archive_node& n, lst& syms) override; protected: - bool is_equal_same_type(const basic & other) const; - unsigned return_type() const; - unsigned calchash() const; - ex expand(unsigned options=0) const; + bool is_equal_same_type(const basic & other) const override; + unsigned return_type() const override; + unsigned calchash() const override; + ex expand(unsigned options=0) const override; // new virtual functions which can be overridden by derived classes protected: diff --git a/ginac/factor.cpp b/ginac/factor.cpp index e9b2569b..34095e31 100644 --- a/ginac/factor.cpp +++ b/ginac/factor.cpp @@ -1831,7 +1831,7 @@ static upvec univar_diophant(const upvec& a, const ex& x, unsigned int m, unsign struct make_modular_map : public map_function { cl_modint_ring R; make_modular_map(const cl_modint_ring& R_) : R(R_) { } - ex operator()(const ex& e) + ex operator()(const ex& e) override { if ( is_a(e) || is_a(e) ) { return e.map(*this); @@ -2456,7 +2456,7 @@ static ex factor_multivariate(const ex& poly, const exset& syms) */ struct find_symbols_map : public map_function { exset syms; - ex operator()(const ex& e) + ex operator()(const ex& e) override { if ( is_a(e) ) { syms.insert(e); @@ -2504,7 +2504,7 @@ static ex factor_sqrfree(const ex& poly) struct apply_factor_map : public map_function { unsigned options; apply_factor_map(unsigned options_) : options(options_) { } - ex operator()(const ex& e) + ex operator()(const ex& e) override { if ( e.info(info_flags::polynomial) ) { return factor(e, options); diff --git a/ginac/fail.h b/ginac/fail.h index 882f7406..cda726f7 100644 --- a/ginac/fail.h +++ b/ginac/fail.h @@ -35,7 +35,7 @@ class fail : public basic // functions overriding virtual functions from base classes protected: - unsigned return_type() const { return return_types::noncommutative_composite; }; + unsigned return_type() const override { return return_types::noncommutative_composite; }; // non-virtual functions in this class protected: diff --git a/ginac/fderivative.h b/ginac/fderivative.h index 09d8644b..a646eacf 100644 --- a/ginac/fderivative.h +++ b/ginac/fderivative.h @@ -59,18 +59,18 @@ public: // functions overriding virtual functions from base classes public: - void print(const print_context & c, unsigned level = 0) const; - ex eval(int level = 0) const; - ex evalf(int level = 0) const; - ex series(const relational & r, int order, unsigned options = 0) const; - ex thiscontainer(const exvector & v) const; - ex thiscontainer(exvector && v) const; - void archive(archive_node& n) const; - void read_archive(const archive_node& n, lst& syms); + void print(const print_context & c, unsigned level = 0) const override; + ex eval(int level = 0) const override; + ex evalf(int level = 0) const override; + ex series(const relational & r, int order, unsigned options = 0) const override; + ex thiscontainer(const exvector & v) const override; + ex thiscontainer(exvector && v) const override; + void archive(archive_node& n) const override; + void read_archive(const archive_node& n, lst& syms) override; protected: - ex derivative(const symbol & s) const; - bool is_equal_same_type(const basic & other) const; - bool match_same_type(const basic & other) const; + ex derivative(const symbol & s) const override; + bool is_equal_same_type(const basic & other) const override; + bool match_same_type(const basic & other) const override; // non-virtual functions in this class protected: diff --git a/ginac/function.hppy b/ginac/function.hppy index 03def530..b54f41f3 100644 --- a/ginac/function.hppy +++ b/ginac/function.hppy @@ -225,28 +225,28 @@ public: // functions overriding virtual functions from base classes public: - void print(const print_context & c, unsigned level = 0) const; - unsigned precedence() const {return 70;} - ex expand(unsigned options=0) const; - ex eval(int level=0) const; - ex evalf(int level=0) const; - ex eval_ncmul(const exvector & v) const; - unsigned calchash() const; - ex series(const relational & r, int order, unsigned options = 0) const; - ex thiscontainer(const exvector & v) const; - ex thiscontainer(exvector && v) const; - ex conjugate() const; - ex real_part() const; - ex imag_part() const; - void archive(archive_node& n) const; - void read_archive(const archive_node& n, lst& syms); - bool info(unsigned inf) const; + void print(const print_context & c, unsigned level = 0) const override; + unsigned precedence() const override {return 70;} + ex expand(unsigned options=0) const override; + ex eval(int level=0) const override; + ex evalf(int level=0) const override; + ex eval_ncmul(const exvector & v) const override; + unsigned calchash() const override; + ex series(const relational & r, int order, unsigned options = 0) const override; + ex thiscontainer(const exvector & v) const override; + ex thiscontainer(exvector && v) const override; + ex conjugate() const override; + ex real_part() const override; + ex imag_part() const override; + void archive(archive_node& n) const override; + void read_archive(const archive_node& n, lst& syms) override; + bool info(unsigned inf) const override; protected: - ex derivative(const symbol & s) const; - bool is_equal_same_type(const basic & other) const; - bool match_same_type(const basic & other) const; - unsigned return_type() const; - return_type_t return_type_tinfo() const; + ex derivative(const symbol & s) const override; + bool is_equal_same_type(const basic & other) const override; + bool match_same_type(const basic & other) const override; + unsigned return_type() const override; + return_type_t return_type_tinfo() const override; // new virtual functions which can be overridden by derived classes // none diff --git a/ginac/idx.h b/ginac/idx.h index 57988250..1e0ad9c7 100644 --- a/ginac/idx.h +++ b/ginac/idx.h @@ -47,18 +47,18 @@ public: // functions overriding virtual functions from base classes public: - bool info(unsigned inf) const; - size_t nops() const; - ex op(size_t i) const; - ex map(map_function & f) const; - ex evalf(int level = 0) const; - ex subs(const exmap & m, unsigned options = 0) const; - void archive(archive_node& n) const; - void read_archive(const archive_node& n, lst& syms); + bool info(unsigned inf) const override; + size_t nops() const override; + ex op(size_t i) const override; + ex map(map_function & f) const override; + ex evalf(int level = 0) const override; + ex subs(const exmap & m, unsigned options = 0) const override; + void archive(archive_node& n) const override; + void read_archive(const archive_node& n, lst& syms) override; protected: - ex derivative(const symbol & s) const; - bool match_same_type(const basic & other) const; - unsigned calchash() const; + ex derivative(const symbol & s) const override; + bool match_same_type(const basic & other) const override; + unsigned calchash() const override; // new virtual functions in this class public: @@ -125,11 +125,11 @@ public: // functions overriding virtual functions from base classes public: - bool is_dummy_pair_same_type(const basic & other) const; - void archive(archive_node& n) const; - void read_archive(const archive_node& n, lst& syms); + bool is_dummy_pair_same_type(const basic & other) const override; + void archive(archive_node& n) const override; + void read_archive(const archive_node& n, lst& syms) override; protected: - bool match_same_type(const basic & other) const; + bool match_same_type(const basic & other) const override; // non-virtual functions in this class public: @@ -175,13 +175,13 @@ public: // functions overriding virtual functions from base classes public: - bool is_dummy_pair_same_type(const basic & other) const; + bool is_dummy_pair_same_type(const basic & other) const override; // complex conjugation - ex conjugate() const { return toggle_dot(); } - void archive(archive_node& n) const; - void read_archive(const archive_node& n, lst& syms); + ex conjugate() const override { return toggle_dot(); } + void archive(archive_node& n) const override; + void read_archive(const archive_node& n, lst& syms) override; protected: - bool match_same_type(const basic & other) const; + bool match_same_type(const basic & other) const override; // non-virtual functions in this class public: diff --git a/ginac/indexed.h b/ginac/indexed.h index 2c4f5511..a04b7425 100644 --- a/ginac/indexed.h +++ b/ginac/indexed.h @@ -143,24 +143,24 @@ public: // functions overriding virtual functions from base classes public: - unsigned precedence() const {return 55;} - bool info(unsigned inf) const; - ex eval(int level = 0) const; - ex real_part() const; - ex imag_part() const; - exvector get_free_indices() const; + unsigned precedence() const override {return 55;} + bool info(unsigned inf) const override; + ex eval(int level = 0) const override; + ex real_part() const override; + ex imag_part() const override; + exvector get_free_indices() const override; /** Save (a.k.a. serialize) indexed object into archive. */ - void archive(archive_node& n) const; + void archive(archive_node& n) const override; /** Read (a.k.a. deserialize) indexed object from archive. */ - void read_archive(const archive_node& n, lst& syms); + void read_archive(const archive_node& n, lst& syms) override; protected: - ex derivative(const symbol & s) const; - ex thiscontainer(const exvector & v) const; - ex thiscontainer(exvector && v) const; - unsigned return_type() const; - return_type_t return_type_tinfo() const { return op(0).return_type_tinfo(); } - ex expand(unsigned options = 0) const; + ex derivative(const symbol & s) const override; + ex thiscontainer(const exvector & v) const override; + ex thiscontainer(exvector && v) const override; + unsigned return_type() const override; + return_type_t return_type_tinfo() const override { return op(0).return_type_tinfo(); } + ex expand(unsigned options = 0) const override; // new virtual functions which can be overridden by derived classes // none diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp index 54d12c9b..7fbc774a 100644 --- a/ginac/inifcns_nstdsums.cpp +++ b/ginac/inifcns_nstdsums.cpp @@ -2360,7 +2360,7 @@ bool convert_parameter_H_to_Li(const lst& l, lst& m, lst& s, ex& pf) // recursivly transforms H to corresponding multiple polylogarithms struct map_trafo_H_convert_to_Li : public map_function { - ex operator()(const ex& e) + ex operator()(const ex& e) override { if (is_a(e) || is_a(e)) { return e.map(*this); @@ -2399,7 +2399,7 @@ struct map_trafo_H_convert_to_Li : public map_function // recursivly transforms H to corresponding zetas struct map_trafo_H_convert_to_zeta : public map_function { - ex operator()(const ex& e) + ex operator()(const ex& e) override { if (is_a(e) || is_a(e)) { return e.map(*this); @@ -2432,7 +2432,7 @@ struct map_trafo_H_convert_to_zeta : public map_function // remove trailing zeros from H-parameters struct map_trafo_H_reduce_trailing_zeros : public map_function { - ex operator()(const ex& e) + ex operator()(const ex& e) override { if (is_a(e) || is_a(e)) { return e.map(*this); @@ -2578,7 +2578,7 @@ ex trafo_H_mult(const ex& h1, const ex& h2) // applies trafo_H_mult recursively on expressions struct map_trafo_H_mult : public map_function { - ex operator()(const ex& e) + ex operator()(const ex& e) override { if (is_a(e)) { return e.map(*this); @@ -2800,7 +2800,7 @@ ex trafo_H_1mxt1px_prepend_one(const ex& e, const ex& arg) // do x -> 1-x transformation struct map_trafo_H_1mx : public map_function { - ex operator()(const ex& e) + ex operator()(const ex& e) override { if (is_a(e) || is_a(e)) { return e.map(*this); @@ -2901,7 +2901,7 @@ struct map_trafo_H_1mx : public map_function // do x -> 1/x transformation struct map_trafo_H_1overx : public map_function { - ex operator()(const ex& e) + ex operator()(const ex& e) override { if (is_a(e) || is_a(e)) { return e.map(*this); @@ -3022,7 +3022,7 @@ struct map_trafo_H_1overx : public map_function // do x -> (1-x)/(1+x) transformation struct map_trafo_H_1mxt1px : public map_function { - ex operator()(const ex& e) + ex operator()(const ex& e) override { if (is_a(e) || is_a(e)) { return e.map(*this); diff --git a/ginac/integral.h b/ginac/integral.h index 2c57222c..f76ac7fc 100644 --- a/ginac/integral.h +++ b/ginac/integral.h @@ -40,28 +40,28 @@ public: // functions overriding virtual functions from base classes public: - unsigned precedence() const {return 45;} - ex eval(int level=0) const; - ex evalf(int level=0) const; - int degree(const ex & s) const; - int ldegree(const ex & s) const; - ex eval_ncmul(const exvector & v) const; - size_t nops() const; - ex op(size_t i) const; - ex & let_op(size_t i); - ex expand(unsigned options = 0) const; - exvector get_free_indices() const; - unsigned return_type() const; - return_type_t return_type_tinfo() const; - ex conjugate() const; - ex eval_integ() const; + unsigned precedence() const override {return 45;} + ex eval(int level=0) const override; + ex evalf(int level=0) const override; + int degree(const ex & s) const override; + int ldegree(const ex & s) const override; + ex eval_ncmul(const exvector & v) const override; + size_t nops() const override; + ex op(size_t i) const override; + ex & let_op(size_t i) override; + ex expand(unsigned options = 0) const override; + exvector get_free_indices() const override; + unsigned return_type() const override; + return_type_t return_type_tinfo() const override; + ex conjugate() const override; + ex eval_integ() const override; /** Save (a.k.a. serialize) object into archive. */ - void archive(archive_node& n) const; + void archive(archive_node& n) const override; /** Read (a.k.a. deserialize) object from archive. */ - void read_archive(const archive_node& n, lst& syms); + void read_archive(const archive_node& n, lst& syms) override; protected: - ex derivative(const symbol & s) const; - ex series(const relational & r, int order, unsigned options = 0) const; + ex derivative(const symbol & s) const override; + ex series(const relational & r, int order, unsigned options = 0) const override; // new virtual functions which can be overridden by derived classes // none diff --git a/ginac/matrix.h b/ginac/matrix.h index 725ea2bb..6081e900 100644 --- a/ginac/matrix.h +++ b/ginac/matrix.h @@ -113,27 +113,27 @@ protected: matrix(unsigned r, unsigned c, exvector && m2); // functions overriding virtual functions from base classes public: - size_t nops() const; - ex op(size_t i) const; - ex & let_op(size_t i); - ex eval(int level=0) const; - ex evalm() const {return *this;} - ex subs(const exmap & m, unsigned options = 0) const; - ex eval_indexed(const basic & i) const; - ex add_indexed(const ex & self, const ex & other) const; - ex scalar_mul_indexed(const ex & self, const numeric & other) const; - bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const; - ex conjugate() const; - ex real_part() const; - ex imag_part() const; + size_t nops() const override; + ex op(size_t i) const override; + ex & let_op(size_t i) override; + ex eval(int level=0) const override; + ex evalm() const override {return *this;} + ex subs(const exmap & m, unsigned options = 0) const override; + ex eval_indexed(const basic & i) const override; + ex add_indexed(const ex & self, const ex & other) const override; + ex scalar_mul_indexed(const ex & self, const numeric & other) const override; + bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override; + ex conjugate() const override; + ex real_part() const override; + ex imag_part() const override; /** Save (a.k.a. serialize) object into archive. */ - void archive(archive_node& n) const; + void archive(archive_node& n) const override; /** Read (a.k.a. deserialize) object from archive. */ - void read_archive(const archive_node& n, lst& syms); + void read_archive(const archive_node& n, lst& syms) override; protected: - bool match_same_type(const basic & other) const; - unsigned return_type() const { return return_types::noncommutative; }; + bool match_same_type(const basic & other) const override; + unsigned return_type() const override { return return_types::noncommutative; }; // non-virtual functions in this class public: diff --git a/ginac/mul.h b/ginac/mul.h index fb3dd9ca..95eba3dc 100644 --- a/ginac/mul.h +++ b/ginac/mul.h @@ -47,43 +47,42 @@ public: // functions overriding virtual functions from base classes public: - unsigned precedence() const {return 50;} - bool info(unsigned inf) const; - bool is_polynomial(const ex & var) const; - int degree(const ex & s) const; - int ldegree(const ex & s) const; - ex coeff(const ex & s, int n = 1) const; - bool has(const ex & other, unsigned options = 0) const; - ex eval(int level=0) const; - ex evalf(int level=0) const; - ex real_part() const; - ex imag_part() const; - ex evalm() const; - ex series(const relational & s, int order, unsigned options = 0) const; - ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const; - numeric integer_content() const; - ex smod(const numeric &xi) const; - numeric max_coefficient() const; - exvector get_free_indices() const; - ex conjugate() const; + unsigned precedence() const override {return 50;} + bool info(unsigned inf) const override; + bool is_polynomial(const ex & var) const override; + int degree(const ex & s) const override; + int ldegree(const ex & s) const override; + ex coeff(const ex & s, int n = 1) const override; + bool has(const ex & other, unsigned options = 0) const override; + ex eval(int level=0) const override; + ex evalf(int level=0) const override; + ex real_part() const override; + ex imag_part() const override; + ex evalm() const override; + ex series(const relational & s, int order, unsigned options = 0) const override; + ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const override; + numeric integer_content() const override; + ex smod(const numeric &xi) const override; + numeric max_coefficient() const override; + exvector get_free_indices() const override; + ex conjugate() const override; protected: - ex derivative(const symbol & s) const; - ex eval_ncmul(const exvector & v) const; - unsigned return_type() const; - return_type_t return_type_tinfo() const; - ex thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming = false) const; - ex thisexpairseq(epvector && vp, const ex & oc, bool do_index_renaming = false) const; - expair split_ex_to_pair(const ex & e) const; - expair combine_ex_with_coeff_to_pair(const ex & e, const ex & c) const; - expair combine_pair_with_coeff_to_pair(const expair & p, const ex & c) const; - ex recombine_pair_to_ex(const expair & p) const; - bool expair_needs_further_processing(epp it); - ex default_overall_coeff() const; - void combine_overall_coeff(const ex & c); - void combine_overall_coeff(const ex & c1, const ex & c2); - bool can_make_flat(const expair & p) const; - ex expand(unsigned options=0) const; - void find_real_imag(ex&, ex&) const; + ex derivative(const symbol & s) const override; + ex eval_ncmul(const exvector & v) const override; + unsigned return_type() const override; + return_type_t return_type_tinfo() const override; + ex thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming = false) const override; + ex thisexpairseq(epvector && vp, const ex & oc, bool do_index_renaming = false) const override; + expair split_ex_to_pair(const ex & e) const override; + expair combine_ex_with_coeff_to_pair(const ex & e, const ex & c) const override; + expair combine_pair_with_coeff_to_pair(const expair & p, const ex & c) const override; + ex recombine_pair_to_ex(const expair & p) const override; + bool expair_needs_further_processing(epp it) override; + ex default_overall_coeff() const override; + void combine_overall_coeff(const ex & c) override; + void combine_overall_coeff(const ex & c1, const ex & c2) override; + bool can_make_flat(const expair & p) const override; + ex expand(unsigned options=0) const override; // new virtual functions which can be overridden by derived classes // none @@ -92,6 +91,7 @@ protected: public: ex algebraic_subs_mul(const exmap & m, unsigned options) const; protected: + void find_real_imag(ex&, ex&) const; void print_overall_coeff(const print_context & c, const char *mul_sym) const; void do_print(const print_context & c, unsigned level) const; void do_print_latex(const print_latex & c, unsigned level) const; diff --git a/ginac/ncmul.h b/ginac/ncmul.h index 92bdbe88..2233b8d7 100644 --- a/ginac/ncmul.h +++ b/ginac/ncmul.h @@ -54,25 +54,25 @@ public: // functions overriding virtual functions from base classes public: - unsigned precedence() const {return 50;} - bool info(unsigned inf) const; - int degree(const ex & s) const; - int ldegree(const ex & s) const; - ex expand(unsigned options=0) const; - ex coeff(const ex & s, int n=1) const; - ex eval(int level=0) const; - ex evalm() const; - exvector get_free_indices() const; - ex thiscontainer(const exvector & v) const; - ex thiscontainer(exvector && v) const; - ex conjugate() const; - ex real_part() const; - ex imag_part() const; + unsigned precedence() const override {return 50;} + bool info(unsigned inf) const override; + int degree(const ex & s) const override; + int ldegree(const ex & s) const override; + ex expand(unsigned options=0) const override; + ex coeff(const ex & s, int n=1) const override; + ex eval(int level=0) const override; + ex evalm() const override; + exvector get_free_indices() const override; + ex thiscontainer(const exvector & v) const override; + ex thiscontainer(exvector && v) const override; + ex conjugate() const override; + ex real_part() const override; + ex imag_part() const override; protected: - ex derivative(const symbol & s) const; - unsigned return_type() const; - return_type_t return_type_tinfo() const; + ex derivative(const symbol & s) const override; + unsigned return_type() const override; + return_type_t return_type_tinfo() const override; // new virtual functions which can be overridden by derived classes // none diff --git a/ginac/normal.cpp b/ginac/normal.cpp index e30afda6..bcb2a398 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -2026,7 +2026,7 @@ static ex replace_with_symbol(const ex & e, exmap & repl) struct normal_map_function : public map_function { int level; normal_map_function(int l) : level(l) {} - ex operator()(const ex & e) { return normal(e, level); } + ex operator()(const ex & e) override { return normal(e, level); } }; /** Default implementation of ex::normal(). It normalizes the children and diff --git a/ginac/numeric.h b/ginac/numeric.h index aa17d801..4d3135d5 100644 --- a/ginac/numeric.h +++ b/ginac/numeric.h @@ -96,35 +96,35 @@ public: // functions overriding virtual functions from base classes public: - unsigned precedence() const {return 30;} - bool info(unsigned inf) const; - bool is_polynomial(const ex & var) const; - int degree(const ex & s) const; - int ldegree(const ex & s) const; - ex coeff(const ex & s, int n = 1) const; - bool has(const ex &other, unsigned options = 0) const; - ex eval(int level = 0) const; - ex evalf(int level = 0) const; - ex subs(const exmap & m, unsigned options = 0) const { return subs_one_level(m, options); } // overwrites basic::subs() for performance reasons - ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const; - ex to_rational(exmap & repl) const; - ex to_polynomial(exmap & repl) const; - numeric integer_content() const; - ex smod(const numeric &xi) const; - numeric max_coefficient() const; - ex conjugate() const; - ex real_part() const; - ex imag_part() const; + unsigned precedence() const override {return 30;} + bool info(unsigned inf) const override; + bool is_polynomial(const ex & var) const override; + int degree(const ex & s) const override; + int ldegree(const ex & s) const override; + ex coeff(const ex & s, int n = 1) const override; + bool has(const ex &other, unsigned options = 0) const override; + ex eval(int level = 0) const override; + ex evalf(int level = 0) const override; + ex subs(const exmap & m, unsigned options = 0) const override { return subs_one_level(m, options); } // overwrites basic::subs() for performance reasons + ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const override; + ex to_rational(exmap & repl) const override; + ex to_polynomial(exmap & repl) const override; + numeric integer_content() const override; + ex smod(const numeric &xi) const override; + numeric max_coefficient() const override; + ex conjugate() const override; + ex real_part() const override; + ex imag_part() const override; /** Save (a.k.a. serialize) object into archive. */ - void archive(archive_node& n) const; + void archive(archive_node& n) const override; /** Read (a.k.a. deserialize) object from archive. */ - void read_archive(const archive_node& n, lst& syms); + void read_archive(const archive_node& n, lst& syms) override; protected: /** Implementation of ex::diff for a numeric always returns 0. * @see ex::diff */ - ex derivative(const symbol &s) const { return 0; } - bool is_equal_same_type(const basic &other) const; - unsigned calchash() const; + ex derivative(const symbol &s) const override { return 0; } + bool is_equal_same_type(const basic &other) const override; + unsigned calchash() const override; // new virtual functions which can be overridden by derived classes // (none) diff --git a/ginac/power.h b/ginac/power.h index 3d5f1873..0d8eb49e 100644 --- a/ginac/power.h +++ b/ginac/power.h @@ -50,37 +50,37 @@ public: // functions overriding virtual functions from base classes public: - unsigned precedence() const {return 60;} - bool info(unsigned inf) const; - size_t nops() const; - ex op(size_t i) const; - ex map(map_function & f) const; - bool is_polynomial(const ex & var) const; - int degree(const ex & s) const; - int ldegree(const ex & s) const; - ex coeff(const ex & s, int n = 1) const; - ex eval(int level=0) const; - ex evalf(int level=0) const; - ex evalm() const; - ex series(const relational & s, int order, unsigned options = 0) const; - ex subs(const exmap & m, unsigned options = 0) const; - bool has(const ex & other, unsigned options = 0) const; - ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const; - ex to_rational(exmap & repl) const; - ex to_polynomial(exmap & repl) const; - ex conjugate() const; - ex real_part() const; - ex imag_part() const; + unsigned precedence() const override {return 60;} + bool info(unsigned inf) const override; + size_t nops() const override; + ex op(size_t i) const override; + ex map(map_function & f) const override; + bool is_polynomial(const ex & var) const override; + int degree(const ex & s) const override; + int ldegree(const ex & s) const override; + ex coeff(const ex & s, int n = 1) const override; + ex eval(int level=0) const override; + ex evalf(int level=0) const override; + ex evalm() const override; + ex series(const relational & s, int order, unsigned options = 0) const override; + ex subs(const exmap & m, unsigned options = 0) const override; + bool has(const ex & other, unsigned options = 0) const override; + ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const override; + ex to_rational(exmap & repl) const override; + ex to_polynomial(exmap & repl) const override; + ex conjugate() const override; + ex real_part() const override; + ex imag_part() const override; /** Save (a.k.a. serialize) object into archive. */ - void archive(archive_node& n) const; + void archive(archive_node& n) const override; /** Read (a.k.a. deserialize) object from archive. */ - void read_archive(const archive_node& n, lst& syms); + void read_archive(const archive_node& n, lst& syms) override; protected: - ex derivative(const symbol & s) const; - ex eval_ncmul(const exvector & v) const; - unsigned return_type() const; - return_type_t return_type_tinfo() const; - ex expand(unsigned options = 0) const; + ex derivative(const symbol & s) const override; + ex eval_ncmul(const exvector & v) const override; + unsigned return_type() const override; + return_type_t return_type_tinfo() const override; + ex expand(unsigned options = 0) const override; // new virtual functions which can be overridden by derived classes // none diff --git a/ginac/print.h b/ginac/print.h index 34456cd7..307dc45e 100644 --- a/ginac/print.h +++ b/ginac/print.h @@ -199,9 +199,9 @@ public: typedef void (*F)(const T &, const C &, unsigned); print_ptrfun_handler(F f_) : f(f_) {} - print_ptrfun_handler *duplicate() const { return new print_ptrfun_handler(*this); } + print_ptrfun_handler *duplicate() const override { return new print_ptrfun_handler(*this); } - void operator()(const basic & obj, const print_context & c, unsigned level) const + void operator()(const basic & obj, const print_context & c, unsigned level) const override { // Call the supplied function f(dynamic_cast(obj), dynamic_cast(c), level); @@ -218,9 +218,9 @@ public: typedef void (T::*F)(const C & c, unsigned level) const; print_memfun_handler(F f_) : f(f_) {} - print_memfun_handler *duplicate() const { return new print_memfun_handler(*this); } + print_memfun_handler *duplicate() const override { return new print_memfun_handler(*this); } - void operator()(const basic & obj, const print_context & c, unsigned level) const + void operator()(const basic & obj, const print_context & c, unsigned level) const override { // Call the supplied member function return (dynamic_cast(obj).*f)(dynamic_cast(c), level); diff --git a/ginac/pseries.h b/ginac/pseries.h index cdac31da..3a36e6d6 100644 --- a/ginac/pseries.h +++ b/ginac/pseries.h @@ -43,30 +43,30 @@ public: // functions overriding virtual functions from base classes public: - unsigned precedence() const {return 38;} // for clarity just below add::precedence - size_t nops() const; - ex op(size_t i) const; - int degree(const ex &s) const; - int ldegree(const ex &s) const; - ex coeff(const ex &s, int n = 1) const; - ex collect(const ex &s, bool distributed = false) const; - ex eval(int level=0) const; - ex evalf(int level=0) const; - ex series(const relational & r, int order, unsigned options = 0) const; - ex subs(const exmap & m, unsigned options = 0) const; - ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const; - ex expand(unsigned options = 0) const; - ex conjugate() const; - ex real_part() const; - ex imag_part() const; - ex eval_integ() const; - ex evalm() const; + unsigned precedence() const override {return 38;} // for clarity just below add::precedence + size_t nops() const override; + ex op(size_t i) const override; + int degree(const ex &s) const override; + int ldegree(const ex &s) const override; + ex coeff(const ex &s, int n = 1) const override; + ex collect(const ex &s, bool distributed = false) const override; + ex eval(int level=0) const override; + ex evalf(int level=0) const override; + ex series(const relational & r, int order, unsigned options = 0) const override; + ex subs(const exmap & m, unsigned options = 0) const override; + ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const override; + ex expand(unsigned options = 0) const override; + ex conjugate() const override; + ex real_part() const override; + ex imag_part() const override; + ex eval_integ() const override; + ex evalm() const override; /** Save (a.k.a. serialize) object into archive. */ - void archive(archive_node& n) const; + void archive(archive_node& n) const override; /** Read (a.k.a. deserialize) object from archive. */ - void read_archive(const archive_node& n, lst& syms); + void read_archive(const archive_node& n, lst& syms) override; protected: - ex derivative(const symbol & s) const; + ex derivative(const symbol & s) const override; // non-virtual functions in this class public: diff --git a/ginac/registrar.h b/ginac/registrar.h index 5c97e6d1..5e2b0e49 100644 --- a/ginac/registrar.h +++ b/ginac/registrar.h @@ -151,9 +151,9 @@ public: \ GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(classname, supername) \ public: \ classname(); \ - virtual classname * duplicate() const { return new classname(*this); } \ + classname * duplicate() const override { return new classname(*this); } \ \ - virtual void accept(GiNaC::visitor & v) const \ + void accept(GiNaC::visitor & v) const override \ { \ if (visitor *p = dynamic_cast(&v)) \ p->visit(*this); \ @@ -161,7 +161,7 @@ public: \ inherited::accept(v); \ } \ protected: \ - virtual int compare_same_type(const GiNaC::basic & other) const; \ + int compare_same_type(const GiNaC::basic & other) const override; \ private: diff --git a/ginac/relational.h b/ginac/relational.h index 6983cbfa..c8bf8b6d 100644 --- a/ginac/relational.h +++ b/ginac/relational.h @@ -52,24 +52,24 @@ public: // functions overriding virtual functions from base classes public: - unsigned precedence() const {return 20;} - bool info(unsigned inf) const; - size_t nops() const; - ex op(size_t i) const; - ex map(map_function & f) const; - ex subs(const exmap & m, unsigned options = 0) const; - ex eval(int level=0) const; + unsigned precedence() const override {return 20;} + bool info(unsigned inf) const override; + size_t nops() const override; + ex op(size_t i) const override; + ex map(map_function & f) const override; + ex subs(const exmap & m, unsigned options = 0) const override; + ex eval(int level=0) const override; /** Save (a.k.a. serialize) object into archive. */ - void archive(archive_node& n) const; + void archive(archive_node& n) const override; /** Read (a.k.a. deserialize) object from archive. */ - void read_archive(const archive_node& n, lst& syms); + void read_archive(const archive_node& n, lst& syms) override; protected: - ex eval_ncmul(const exvector & v) const; - bool match_same_type(const basic & other) const; - unsigned return_type() const; - return_type_t return_type_tinfo() const; - unsigned calchash() const; + ex eval_ncmul(const exvector & v) const override; + bool match_same_type(const basic & other) const override; + unsigned return_type() const override; + return_type_t return_type_tinfo() const override; + unsigned calchash() const override; // new virtual functions which can be overridden by derived classes protected: diff --git a/ginac/structure.h b/ginac/structure.h index b664a6af..1301ad2b 100644 --- a/ginac/structure.h +++ b/ginac/structure.h @@ -126,77 +126,77 @@ public: // All these are just defaults that can be specialized by the user public: // evaluation - ex eval(int level = 0) const { return hold(); } - ex evalf(int level = 0) const { return inherited::evalf(level); } - ex evalm() const { return inherited::evalm(); } + ex eval(int level = 0) const override { return hold(); } + ex evalf(int level = 0) const override { return inherited::evalf(level); } + ex evalm() const override { return inherited::evalm(); } protected: - ex eval_ncmul(const exvector & v) const { return hold_ncmul(v); } + ex eval_ncmul(const exvector & v) const override { return hold_ncmul(v); } public: - ex eval_indexed(const basic & i) const { return i.hold(); } + ex eval_indexed(const basic & i) const override { return i.hold(); } // printing - void print(const print_context & c, unsigned level = 0) const { inherited::print(c, level); } - unsigned precedence() const { return 70; } + void print(const print_context & c, unsigned level = 0) const override { inherited::print(c, level); } + unsigned precedence() const override { return 70; } // info - bool info(unsigned inf) const { return false; } + bool info(unsigned inf) const override { return false; } // operand access - size_t nops() const { return 0; } - ex op(size_t i) const { return inherited::op(i); } - ex operator[](const ex & index) const { return inherited::operator[](index); } - ex operator[](size_t i) const { return inherited::operator[](i); } - ex & let_op(size_t i) { return inherited::let_op(i); } - ex & operator[](const ex & index) { return inherited::operator[](index); } - ex & operator[](size_t i) { return inherited::operator[](i); } + size_t nops() const override { return 0; } + ex op(size_t i) const override { return inherited::op(i); } + ex operator[](const ex & index) const override { return inherited::operator[](index); } + ex operator[](size_t i) const override { return inherited::operator[](i); } + ex & let_op(size_t i) override { return inherited::let_op(i); } + ex & operator[](const ex & index) override { return inherited::operator[](index); } + ex & operator[](size_t i) override { return inherited::operator[](i); } // pattern matching - bool has(const ex & other, unsigned options = 0) const { return inherited::has(other, options); } - bool match(const ex & pattern, exmap& repl_lst) const { return inherited::match(pattern, repl_lst); } + bool has(const ex & other, unsigned options = 0) const override { return inherited::has(other, options); } + bool match(const ex & pattern, exmap& repl_lst) const override { return inherited::match(pattern, repl_lst); } protected: - bool match_same_type(const basic & other) const { return true; } + bool match_same_type(const basic & other) const override { return true; } public: // substitutions - ex subs(const exmap & m, unsigned options = 0) const { return inherited::subs(m, options); } + ex subs(const exmap & m, unsigned options = 0) const override { return inherited::subs(m, options); } // function mapping - ex map(map_function & f) const { return inherited::map(f); } + ex map(map_function & f) const override { return inherited::map(f); } // degree/coeff - int degree(const ex & s) const { return inherited::degree(s); } - int ldegree(const ex & s) const { return inherited::ldegree(s); } - ex coeff(const ex & s, int n = 1) const { return inherited::coeff(s, n); } + int degree(const ex & s) const override { return inherited::degree(s); } + int ldegree(const ex & s) const override { return inherited::ldegree(s); } + ex coeff(const ex & s, int n = 1) const override { return inherited::coeff(s, n); } // expand/collect - ex expand(unsigned options = 0) const { return inherited::expand(options); } - ex collect(const ex & s, bool distributed = false) const { return inherited::collect(s, distributed); } + ex expand(unsigned options = 0) const override { return inherited::expand(options); } + ex collect(const ex & s, bool distributed = false) const override { return inherited::collect(s, distributed); } // differentiation and series expansion protected: - ex derivative(const symbol & s) const { return inherited::derivative(s); } + ex derivative(const symbol & s) const override { return inherited::derivative(s); } public: - ex series(const relational & r, int order, unsigned options = 0) const { return inherited::series(r, order, options); } + ex series(const relational & r, int order, unsigned options = 0) const override { return inherited::series(r, order, options); } // rational functions - ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const { return inherited::normal(repl, rev_lookup, level); } - ex to_rational(exmap & repl) const { return inherited::to_rational(repl); } - ex to_polynomial(exmap & repl) const { return inherited::to_polynomial(repl); } + ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const override { return inherited::normal(repl, rev_lookup, level); } + ex to_rational(exmap & repl) const override { return inherited::to_rational(repl); } + ex to_polynomial(exmap & repl) const override { return inherited::to_polynomial(repl); } // polynomial algorithms - numeric integer_content() const { return 1; } - ex smod(const numeric & xi) const { return *this; } - numeric max_coefficient() const { return 1; } + numeric integer_content() const override { return 1; } + ex smod(const numeric & xi) const override { return *this; } + numeric max_coefficient() const override { return 1; } // indexed objects - exvector get_free_indices() const { return exvector(); } - ex add_indexed(const ex & self, const ex & other) const { return self + other; } - ex scalar_mul_indexed(const ex & self, const numeric & other) const { return self * ex(other); } - bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const { return false; } + exvector get_free_indices() const override { return exvector(); } + ex add_indexed(const ex & self, const ex & other) const override { return self + other; } + ex scalar_mul_indexed(const ex & self, const numeric & other) const override { return self * ex(other); } + bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override { return false; } // noncommutativity - unsigned return_type() const { return return_types::commutative; } - return_type_t return_type_tinfo() const + unsigned return_type() const override { return return_types::commutative; } + return_type_t return_type_tinfo() const override { return_type_t r; r.rl = 0; @@ -205,7 +205,7 @@ public: } protected: - bool is_equal_same_type(const basic & other) const + bool is_equal_same_type(const basic & other) const override { GINAC_ASSERT(is_a(other)); const structure & o = static_cast(other); @@ -213,7 +213,7 @@ protected: return this->struct_is_equal(&obj, &o.obj); } - unsigned calchash() const { return inherited::calchash(); } + unsigned calchash() const override { return inherited::calchash(); } // non-virtual functions in this class public: diff --git a/ginac/symbol.h b/ginac/symbol.h index 3a8505c0..68b747e8 100644 --- a/ginac/symbol.h +++ b/ginac/symbol.h @@ -45,33 +45,36 @@ public: // functions overriding virtual functions from base classes public: - bool info(unsigned inf) const; - ex eval(int level = 0) const { return *this; } // for performance reasons - ex evalf(int level = 0) const { return *this; } // overwrites basic::evalf() for performance reasons - ex series(const relational & s, int order, unsigned options = 0) const; - ex subs(const exmap & m, unsigned options = 0) const { return subs_one_level(m, options); } // overwrites basic::subs() for performance reasons - ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const; - ex to_rational(exmap & repl) const; - ex to_polynomial(exmap & repl) const; - ex conjugate() const; - ex real_part() const; - ex imag_part() const; - bool is_polynomial(const ex & var) const; + bool info(unsigned inf) const override; + ex eval(int level = 0) const override { return *this; } // for performance reasons + ex evalf(int level = 0) const override { return *this; } // overwrites basic::evalf() for performance reasons + ex series(const relational & s, int order, unsigned options = 0) const override; + ex subs(const exmap & m, unsigned options = 0) const override { return subs_one_level(m, options); } // overwrites basic::subs() for performance reasons + ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const override; + ex to_rational(exmap & repl) const override; + ex to_polynomial(exmap & repl) const override; + ex conjugate() const override; + ex real_part() const override; + ex imag_part() const override; + bool is_polynomial(const ex & var) const override; /** Save (a.k.a. serialize) object into archive. */ - void archive(archive_node& n) const; + void archive(archive_node& n) const override; /** Read (a.k.a. deserialize) object from archive. */ - void read_archive(const archive_node& n, lst& syms); + void read_archive(const archive_node& n, lst& syms) override; protected: - ex derivative(const symbol & s) const; - bool is_equal_same_type(const basic & other) const; - unsigned calchash() const; + ex derivative(const symbol & s) const override; + bool is_equal_same_type(const basic & other) const override; + unsigned calchash() const override; + + // new virtual functions which can be overridden by derived classes +public: + virtual unsigned get_domain() const { return domain::complex; } // non-virtual functions in this class public: void set_name(const std::string & n) { name = n; } void set_TeX_name(const std::string & n) { TeX_name = n; } std::string get_name() const; - virtual unsigned get_domain() const { return domain::complex; } protected: void do_print(const print_context & c, unsigned level) const; void do_print_latex(const print_latex & c, unsigned level) const; @@ -98,13 +101,13 @@ public: explicit realsymbol(const std::string & initname); realsymbol(const std::string & initname, const std::string & texname); - unsigned get_domain() const { return domain::real; } + unsigned get_domain() const override { return domain::real; } - ex conjugate() const { return *this; } - ex real_part() const { return *this; } - ex imag_part() const { return 0; } + ex conjugate() const override { return *this; } + ex real_part() const override { return *this; } + ex imag_part() const override { return 0; } - realsymbol* duplicate() const { return new realsymbol(*this); } + realsymbol* duplicate() const override { return new realsymbol(*this); } }; GINAC_DECLARE_UNARCHIVER(realsymbol); @@ -117,9 +120,9 @@ public: explicit possymbol(const std::string & initname); possymbol(const std::string & initname, const std::string & texname); - unsigned get_domain() const { return domain::positive; } + unsigned get_domain() const override { return domain::positive; } - possymbol* duplicate() const { return new possymbol(*this); } + possymbol* duplicate() const override { return new possymbol(*this); } }; GINAC_DECLARE_UNARCHIVER(possymbol); diff --git a/ginac/symmetry.h b/ginac/symmetry.h index 6839e756..c369aed3 100644 --- a/ginac/symmetry.h +++ b/ginac/symmetry.h @@ -61,6 +61,15 @@ public: /** Create node with two children. */ symmetry(symmetry_type t, const symmetry &c1, const symmetry &c2); + // functions overriding virtual functions from base classes +public: + /** Save (a.k.a. serialize) object into archive. */ + void archive(archive_node& n) const override; + /** Read (a.k.a. deserialize) object from archive. */ + void read_archive(const archive_node& n, lst& syms) override; +protected: + unsigned calchash() const override; + // non-virtual functions in this class public: /** Get symmetry type. */ @@ -84,15 +93,9 @@ public: bool has_nonsymmetric() const; /** Check whether this node involves a cyclic symmetry. */ bool has_cyclic() const; - - /** Save (a.k.a. serialize) object into archive. */ - void archive(archive_node& n) const; - /** Read (a.k.a. deserialize) object from archive. */ - void read_archive(const archive_node& n, lst& syms); protected: void do_print(const print_context & c, unsigned level) const; void do_print_tree(const print_tree & c, unsigned level) const; - unsigned calchash() const; // member variables private: diff --git a/ginac/tensor.h b/ginac/tensor.h index 8dd667af..dbe0f1e9 100644 --- a/ginac/tensor.h +++ b/ginac/tensor.h @@ -37,7 +37,7 @@ class tensor : public basic // functions overriding virtual functions from base classes protected: - unsigned return_type() const { return return_types::noncommutative_composite; } + unsigned return_type() const override { return return_types::noncommutative_composite; } // non-virtual functions in this class public: @@ -56,13 +56,14 @@ class tensdelta : public tensor // functions overriding virtual functions from base classes public: - bool info(unsigned inf) const; - ex eval_indexed(const basic & i) const; - bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const; + bool info(unsigned inf) const override; + ex eval_indexed(const basic & i) const override; + bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override; +protected: + unsigned return_type() const override { return return_types::commutative; } // non-virtual functions in this class protected: - unsigned return_type() const { return return_types::commutative; } void do_print(const print_context & c, unsigned level) const; void do_print_latex(const print_latex & c, unsigned level) const; }; @@ -78,13 +79,14 @@ class tensmetric : public tensor // functions overriding virtual functions from base classes public: - bool info(unsigned inf) const; - ex eval_indexed(const basic & i) const; - bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const; + bool info(unsigned inf) const override; + ex eval_indexed(const basic & i) const override; + bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override; +protected: + unsigned return_type() const override { return return_types::commutative; } // non-virtual functions in this class protected: - unsigned return_type() const { return return_types::commutative; } void do_print(const print_context & c, unsigned level) const; }; GINAC_DECLARE_UNARCHIVER(tensmetric); @@ -104,16 +106,18 @@ public: // functions overriding virtual functions from base classes public: - bool info(unsigned inf) const; - ex eval_indexed(const basic & i) const; + bool info(unsigned inf) const override; + ex eval_indexed(const basic & i) const override; /** Save (a.k.a. serialize) object into archive. */ - void archive(archive_node& n) const; + void archive(archive_node& n) const override; /** Read (a.k.a. deserialize) object from archive. */ - void read_archive(const archive_node& n, lst& syms); + void read_archive(const archive_node& n, lst& syms) override; +protected: + unsigned return_type() const override { return return_types::commutative; } + // non-virtual functions in this class protected: - unsigned return_type() const { return return_types::commutative; } void do_print(const print_context & c, unsigned level) const; void do_print_latex(const print_latex & c, unsigned level) const; @@ -134,9 +138,9 @@ class spinmetric : public tensmetric // functions overriding virtual functions from base classes public: - bool info(unsigned inf) const; - ex eval_indexed(const basic & i) const; - bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const; + bool info(unsigned inf) const override; + ex eval_indexed(const basic & i) const override; + bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override; protected: void do_print(const print_context & c, unsigned level) const; @@ -158,17 +162,19 @@ public: // functions overriding virtual functions from base classes public: - bool info(unsigned inf) const; - ex eval_indexed(const basic & i) const; - bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const; + bool info(unsigned inf) const override; + ex eval_indexed(const basic & i) const override; + bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const override; /** Save (a.k.a. serialize) object into archive. */ - void archive(archive_node& n) const; + void archive(archive_node& n) const override; /** Read (a.k.a. deserialize) object from archive. */ - void read_archive(const archive_node& n, lst& syms); + void read_archive(const archive_node& n, lst& syms) override; +protected: + unsigned return_type() const override { return return_types::commutative; } + // non-virtual functions in this class protected: - unsigned return_type() const { return return_types::commutative; } void do_print(const print_context & c, unsigned level) const; void do_print_latex(const print_latex & c, unsigned level) const; diff --git a/ginac/wildcard.h b/ginac/wildcard.h index d157d9b7..6a66ae3f 100644 --- a/ginac/wildcard.h +++ b/ginac/wildcard.h @@ -41,14 +41,14 @@ public: // functions overriding virtual functions from base classes public: - bool match(const ex & pattern, exmap& repl_lst) const; + bool match(const ex & pattern, exmap& repl_lst) const override; /** Save (a.k.a. serialize) object into archive. */ - void archive(archive_node& n) const; + void archive(archive_node& n) const override; /** Read (a.k.a. deserialize) object from archive. */ - void read_archive(const archive_node& n, lst& syms); + void read_archive(const archive_node& n, lst& syms) override; protected: - unsigned calchash() const; + unsigned calchash() const override; // non-virtual functions in this class public: diff --git a/ginsh/ginsh_parser.ypp b/ginsh/ginsh_parser.ypp index bb62ed05..6210deff 100644 --- a/ginsh/ginsh_parser.ypp +++ b/ginsh/ginsh_parser.ypp @@ -472,7 +472,7 @@ class apply_map_function : public map_function { public: apply_map_function(const ex & a) : apply(a) {} virtual ~apply_map_function() {} - ex operator()(const ex & e) { return apply.subs(wild() == e, true); } + ex operator()(const ex & e) override { return apply.subs(wild() == e, true); } }; static ex f_map(const exprseq &e)