From acae7ab5a4dc94d1f54ba794f32f5764cdb4d704 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Sun, 1 Nov 2015 23:48:05 +0100 Subject: [PATCH] Replace use of NULL by C++11 nullptr. --- check/randomize_serials.cpp | 2 +- check/test_runner.h | 2 +- ginac/basic.cpp | 4 ++-- ginac/class_info.h | 8 ++++---- ginac/container.h | 2 +- ginac/excompiler.cpp | 4 ++-- ginac/function.cppy | 10 +++++----- ginac/function.hppy | 4 ++-- ginac/normal.cpp | 16 ++++++++-------- ginac/normal.h | 4 ++-- ginac/power.cpp | 12 ++++++------ ginac/pseries.cpp | 2 +- ginac/symmetry.cpp | 2 +- 13 files changed, 36 insertions(+), 36 deletions(-) diff --git a/check/randomize_serials.cpp b/check/randomize_serials.cpp index 5016a0c0..5603452a 100644 --- a/check/randomize_serials.cpp +++ b/check/randomize_serials.cpp @@ -45,7 +45,7 @@ using namespace std; */ void randomify_symbol_serials() { - srand(time(NULL)); + srand(time(nullptr)); const int m = rand() % 666; for (int s=0; s 2) value = 0; diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 79d83b55..563dd7d5 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -297,12 +297,12 @@ ex basic::map(map_function & f) const if (num == 0) return *this; - basic *copy = NULL; + basic *copy = nullptr; for (size_t i=0; ilet_op(i) = n; } diff --git a/ginac/class_info.h b/ginac/class_info.h index 588a73b9..1d3ed3d2 100644 --- a/ginac/class_info.h +++ b/ginac/class_info.h @@ -40,13 +40,13 @@ namespace GiNaC { template class class_info { public: - class_info(const OPT & o) : options(o), next(first), parent(NULL) + class_info(const OPT & o) : options(o), next(first), parent(nullptr) { first = this; parents_identified = false; } - /** Get pointer to class_info of parent class (or NULL). */ + /** Get pointer to class_info of parent class (or nullptr). */ class_info *get_parent() const { identify_parents(); @@ -155,7 +155,7 @@ void class_info::dump_hierarchy(bool verbose) tree.push_back(tree_node(p)); // Identify children for all nodes and find the root - tree_node *root = NULL; + tree_node *root = nullptr; for (typename std::vector::iterator i = tree.begin(); i != tree.end(); ++i) { class_info *p = i->info->get_parent(); if (p) { @@ -190,7 +190,7 @@ void class_info::identify_parents() } } -template class_info *class_info::first = NULL; +template class_info *class_info::first = nullptr; template bool class_info::parents_identified = false; } // namespace GiNaC diff --git a/ginac/container.h b/ginac/container.h index 6cdc7cb7..3c9d5601 100644 --- a/ginac/container.h +++ b/ginac/container.h @@ -394,7 +394,7 @@ public: protected: ex conjugate() const { - STLT *newcont = NULL; + STLT *newcont = nullptr; for (const_iterator i=this->seq.begin(); i!=this->seq.end(); ++i) { if (newcont) { newcont->push_back(i->conjugate()); diff --git a/ginac/excompiler.cpp b/ginac/excompiler.cpp index d7897c01..36cb8ffc 100644 --- a/ginac/excompiler.cpp +++ b/ginac/excompiler.cpp @@ -153,9 +153,9 @@ public: */ void* link_so_file(const std::string filename, bool clean_up) { - void* module = NULL; + void* module = nullptr; module = dlopen(filename.c_str(), RTLD_NOW); - if (module == NULL) { + if (module == nullptr) { throw std::runtime_error("excompiler::link_so_file: could not open compiled module!"); } diff --git a/ginac/function.cppy b/ginac/function.cppy index 517f4566..45f33ec1 100644 --- a/ginac/function.cppy +++ b/ginac/function.cppy @@ -304,7 +304,7 @@ void function::print(const print_context & c, unsigned level) const next_context: unsigned id = pc_info->options.get_id(); - if (id >= pdt.size() || pdt[id] == NULL) { + if (id >= pdt.size() || pdt[id] == nullptr) { // Method not found, try parent print_context class const print_context_class_info *parent_pc_info = pc_info->get_parent(); @@ -736,7 +736,7 @@ ex function::pderivative(unsigned diff_param) const // partial differentiation const function_options &opt = registered_functions()[serial]; // No derivative defined? Then return abstract derivative object - if (opt.derivative_f == NULL) + if (opt.derivative_f == nullptr) return fderivative(serial, diff_param, seq); current_serial = serial; @@ -759,7 +759,7 @@ ex function::expl_derivative(const symbol & s) const // explicit differentiation const function_options &opt = registered_functions()[serial]; // No explicit derivative defined? Then this function shall not be called! - if (opt.expl_derivative_f == NULL) + if (opt.expl_derivative_f == nullptr) throw(std::logic_error("function::expl_derivative(): explicit derivation is called, but no such function defined")); current_serial = serial; @@ -780,7 +780,7 @@ ex function::power(const ex & power_param) const // power of function GINAC_ASSERT(serialsetflag(status_flags::dynallocated | status_flags::evaluated); @@ -804,7 +804,7 @@ ex function::expand(unsigned options) const const function_options &opt = registered_functions()[serial]; // No expand defined? Then return the same function with expanded arguments (if required) - if (opt.expand_f == NULL) { + if (opt.expand_f == nullptr) { // Only expand arguments when asked to do so if (options & expand_options::expand_function_args) return inherited::expand(options); diff --git a/ginac/function.hppy b/ginac/function.hppy index b84364da..a5605115 100644 --- a/ginac/function.hppy +++ b/ginac/function.hppy @@ -145,8 +145,8 @@ public: unsigned get_nparams() const { return nparams; } protected: - bool has_derivative() const { return derivative_f != NULL; } - bool has_power() const { return power_f != NULL; } + bool has_derivative() const { return derivative_f != nullptr; } + bool has_power() const { return power_f != nullptr; } void test_and_set_nparams(unsigned n); void set_print_func(unsigned id, print_funcp f); diff --git a/ginac/normal.cpp b/ginac/normal.cpp index 18b4637c..6870b77f 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -961,7 +961,7 @@ ex ex::content(const ex &x) const return lcoeff * c / lcoeff.unit(x); ex cont = _ex0; for (int i=ldeg; i<=deg; i++) - cont = gcd(r.coeff(x, i), cont, NULL, NULL, false); + cont = gcd(r.coeff(x, i), cont, nullptr, nullptr, false); return cont * c; } @@ -1101,7 +1101,7 @@ static ex sr_gcd(const ex &a, const ex &b, sym_desc_vec::const_iterator var) // Remove content from c and d, to be attached to GCD later ex cont_c = c.content(x); ex cont_d = d.content(x); - ex gamma = gcd(cont_c, cont_d, NULL, NULL, false); + ex gamma = gcd(cont_c, cont_d, nullptr, nullptr, false); if (ddeg == 0) return gamma; c = c.primpart(x, cont_c); @@ -1272,9 +1272,9 @@ class gcdheu_failed {}; * * @param a first integer multivariate polynomial (expanded) * @param b second integer multivariate polynomial (expanded) - * @param ca cofactor of polynomial a (returned), NULL to suppress + * @param ca cofactor of polynomial a (returned), nullptr to suppress * calculation of cofactor - * @param cb cofactor of polynomial b (returned), NULL to suppress + * @param cb cofactor of polynomial b (returned), nullptr to suppress * calculation of cofactor * @param var iterator to first element of vector of sym_desc structs * @param res the GCD (returned) @@ -1365,9 +1365,9 @@ static bool heur_gcd_z(ex& res, const ex &a, const ex &b, ex *ca, ex *cb, * * @param a first rational multivariate polynomial (expanded) * @param b second rational multivariate polynomial (expanded) - * @param ca cofactor of polynomial a (returned), NULL to suppress + * @param ca cofactor of polynomial a (returned), nullptr to suppress * calculation of cofactor - * @param cb cofactor of polynomial b (returned), NULL to suppress + * @param cb cofactor of polynomial b (returned), nullptr to suppress * calculation of cofactor * @param var iterator to first element of vector of sym_desc structs * @param res the GCD (returned) @@ -1431,8 +1431,8 @@ static ex gcd_pf_mul(const ex& a, const ex& b, ex* ca, ex* cb); * * @param a first multivariate polynomial * @param b second multivariate polynomial - * @param ca pointer to expression that will receive the cofactor of a, or NULL - * @param cb pointer to expression that will receive the cofactor of b, or NULL + * @param ca pointer to expression that will receive the cofactor of a, or nullptr + * @param cb pointer to expression that will receive the cofactor of b, or nullptr * @param check_args check whether a and b are polynomials with rational * coefficients (defaults to "true") * @return the GCD as a new expression */ diff --git a/ginac/normal.h b/ginac/normal.h index f249cb1a..deb69a97 100644 --- a/ginac/normal.h +++ b/ginac/normal.h @@ -85,8 +85,8 @@ extern ex sprem(const ex &a, const ex &b, const ex &x, bool check_args = true); extern bool divide(const ex &a, const ex &b, ex &q, bool check_args = true); // Polynomial GCD in Z[X], cofactors are returned in ca and cb, if desired -extern ex gcd(const ex &a, const ex &b, ex *ca = NULL, ex *cb = NULL, - bool check_args = true, unsigned options = 0); +extern ex gcd(const ex &a, const ex &b, ex *ca = nullptr, ex *cb = nullptr, + bool check_args = true, unsigned options = 0); // Polynomial LCM in Z[X] extern ex lcm(const ex &a, const ex &b, bool check_args = true); diff --git a/ginac/power.cpp b/ginac/power.cpp index 99a5a3c4..72806768 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -384,8 +384,8 @@ ex power::eval(int level) const const ex & ebasis = level==1 ? basis : basis.eval(level-1); const ex & eexponent = level==1 ? exponent : exponent.eval(level-1); - const numeric *num_basis = NULL; - const numeric *num_exponent = NULL; + const numeric *num_basis = nullptr; + const numeric *num_exponent = nullptr; if (is_exactly_a(ebasis)) { num_basis = &ex_to(ebasis); @@ -1007,7 +1007,7 @@ private: // NB: Partition must be sorted in non-decreasing order. explicit coolmulti(const std::vector& partition) { - head = NULL; + head = nullptr; for (unsigned n = 0; n < partition.size(); ++n) { head = new element(partition[n], head); if (n <= 1) @@ -1022,7 +1022,7 @@ private: void next_permutation() { element *before_k; - if (after_i->next != NULL && i->value >= after_i->next->value) + if (after_i->next != nullptr && i->value >= after_i->next->value) before_k = after_i; else before_k = i; @@ -1036,7 +1036,7 @@ private: } bool finished() const { - return after_i->next == NULL && after_i->value >= head->value; + return after_i->next == nullptr && after_i->value >= head->value; } } cmgen; bool atend; // needed for simplifying iteration over permutations @@ -1053,7 +1053,7 @@ public: { coolmulti::element* it = cmgen.head; size_t i = 0; - while (it != NULL) { + while (it != nullptr) { composition[i] = it->value; it = it->next; ++i; diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index ead7a777..e50af515 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -465,7 +465,7 @@ ex pseries::imag_part() const ex pseries::eval_integ() const { - epvector *newseq = NULL; + epvector *newseq = nullptr; for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) { if (newseq) { newseq->push_back(expair(i->rest.eval_integ(), i->coeff)); diff --git a/ginac/symmetry.cpp b/ginac/symmetry.cpp index 270344e9..71932ffa 100644 --- a/ginac/symmetry.cpp +++ b/ginac/symmetry.cpp @@ -504,7 +504,7 @@ static ex symm(const ex & e, exvector::const_iterator first, exvector::const_ite unsigned *iv = new unsigned[num], *iv2; for (unsigned i=0; i