From e4e1a0ddc5ea64a6b77445fe79151a0d59cb966b Mon Sep 17 00:00:00 2001 From: Hleb Valoshka <375gnu@gmail.com> Date: Sat, 30 Nov 2019 13:07:21 +0300 Subject: [PATCH] Remove deprecated C++ features std::unary_function & std::binary_function were deprecated in C++11 and removed in C++17 --- src/celengine/galaxy.cpp | 6 ++++-- src/celengine/observer.cpp | 2 +- src/celephem/orbit.cpp | 8 ++++---- src/celmodel/mesh.cpp | 6 +----- src/celmodel/model.cpp | 2 +- src/celutil/util.h | 9 +++------ src/tools/cmod/cmodfix/cmodfix.cpp | 11 ++--------- src/tools/cmod/common/cmodops.cpp | 13 ++----------- src/tools/stardb/buildstardb.cpp | 5 ++++- 9 files changed, 22 insertions(+), 40 deletions(-) diff --git a/src/celengine/galaxy.cpp b/src/celengine/galaxy.cpp index d3b792ed..79107aa1 100644 --- a/src/celengine/galaxy.cpp +++ b/src/celengine/galaxy.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include using namespace Eigen; @@ -658,7 +658,9 @@ GalacticForm* buildGalacticForms(const fs::path& filename) // reshuffle the galaxy points randomly...except the first kmin+1 in the center! // the higher that number the stronger the central "glow" - random_shuffle( galacticPoints->begin() + kmin, galacticPoints->end()); + std::random_device rng; + std::mt19937 urng(rng()); + shuffle(galacticPoints->begin() + kmin, galacticPoints->end(), urng); auto* galacticForm = new GalacticForm(); galacticForm->blobs = galacticPoints; diff --git a/src/celengine/observer.cpp b/src/celengine/observer.cpp index 65d0fea8..28af7c64 100644 --- a/src/celengine/observer.cpp +++ b/src/celengine/observer.cpp @@ -498,7 +498,7 @@ void Observer::reverseOrientation() -struct TravelExpFunc : public unary_function +struct TravelExpFunc { double dist, s; diff --git a/src/celephem/orbit.cpp b/src/celephem/orbit.cpp index 14248468..9d4b5fce 100644 --- a/src/celephem/orbit.cpp +++ b/src/celephem/orbit.cpp @@ -196,7 +196,7 @@ EllipticalOrbit::EllipticalOrbit(double _pericenterDistance, // Standard iteration for solving Kepler's Equation -struct SolveKeplerFunc1 : public unary_function +struct SolveKeplerFunc1 { double ecc; double M; @@ -213,7 +213,7 @@ struct SolveKeplerFunc1 : public unary_function // Faster converging iteration for Kepler's Equation; more efficient // than above for orbits with eccentricities greater than 0.3. This // is from Jean Meeus's _Astronomical Algorithms_ (2nd ed), p. 199 -struct SolveKeplerFunc2 : public unary_function +struct SolveKeplerFunc2 { double ecc; double M; @@ -227,7 +227,7 @@ struct SolveKeplerFunc2 : public unary_function }; -struct SolveKeplerLaguerreConway : public unary_function +struct SolveKeplerLaguerreConway { double ecc; double M; @@ -247,7 +247,7 @@ struct SolveKeplerLaguerreConway : public unary_function } }; -struct SolveKeplerLaguerreConwayHyp : public unary_function +struct SolveKeplerLaguerreConwayHyp { double ecc; double M; diff --git a/src/celmodel/mesh.cpp b/src/celmodel/mesh.cpp index 6f447020..331777c4 100644 --- a/src/celmodel/mesh.cpp +++ b/src/celmodel/mesh.cpp @@ -304,16 +304,12 @@ Mesh::remapMaterials(const vector& materialMap) } -class PrimitiveGroupComparator : public std::binary_function +struct PrimitiveGroupComparator { -public: bool operator()(const Mesh::PrimitiveGroup* g0, const Mesh::PrimitiveGroup* g1) const { return g0->materialIndex < g1->materialIndex; } - -private: - int unused; }; diff --git a/src/celmodel/model.cpp b/src/celmodel/model.cpp index a58ab228..eeeacbaa 100644 --- a/src/celmodel/model.cpp +++ b/src/celmodel/model.cpp @@ -381,7 +381,7 @@ Model::usesTextureType(Material::TextureSemantic t) const } -class MeshComparatorAdapter : public std::binary_function +class MeshComparatorAdapter { public: MeshComparatorAdapter(const Model::MeshComparator& c) : diff --git a/src/celutil/util.h b/src/celutil/util.h index 8974bb1f..1b8ba71f 100644 --- a/src/celutil/util.h +++ b/src/celutil/util.h @@ -44,24 +44,21 @@ extern int compareIgnoringCase(const std::string& s1, const std::string& s2); extern int compareIgnoringCase(const std::string& s1, const std::string& s2, int n); extern fs::path LocaleFilename(const fs::path& filename); -class CompareIgnoringCasePredicate : public std::binary_function +struct CompareIgnoringCasePredicate { - public: bool operator()(const std::string&, const std::string&) const; }; -template struct printlineFunc : public std::unary_function +template struct printlineFunc { printlineFunc(std::ostream& o) : out(o) {}; void operator() (T x) { out << x << '\n'; }; std::ostream& out; }; -template struct deleteFunc : public std::unary_function +template struct deleteFunc { - deleteFunc() {}; void operator() (T x) { delete x; }; - int dummy; }; // size in bytes of memory required to store a container data diff --git a/src/tools/cmod/cmodfix/cmodfix.cpp b/src/tools/cmod/cmodfix/cmodfix.cpp index 1628aa85..f27fd21d 100644 --- a/src/tools/cmod/cmodfix/cmodfix.cpp +++ b/src/tools/cmod/cmodfix/cmodfix.cpp @@ -79,7 +79,7 @@ struct Face }; -class VertexComparator : public std::binary_function +class VertexComparator { public: virtual bool compare(const Vertex& a, const Vertex& b) const = 0; @@ -390,19 +390,12 @@ bool operator<(const Mesh::VertexDescription& a, } -class MeshVertexDescComparator : - public std::binary_function +struct MeshVertexDescComparator { -public: - MeshVertexDescComparator() = default; - bool operator()(const Mesh* a, const Mesh* b) const { return a->getVertexDescription() < b->getVertexDescription(); } - -private: - int ignore; }; diff --git a/src/tools/cmod/common/cmodops.cpp b/src/tools/cmod/common/cmodops.cpp index 2fd317fa..904fe11b 100644 --- a/src/tools/cmod/common/cmodops.cpp +++ b/src/tools/cmod/common/cmodops.cpp @@ -24,9 +24,8 @@ using namespace Eigen; using namespace std; -class VertexComparator : public std::binary_function +struct VertexComparator { -public: virtual bool compare(const Vertex& a, const Vertex& b) const = 0; bool operator()(const Vertex& a, const Vertex& b) const @@ -335,23 +334,15 @@ bool operator<(const Mesh::VertexDescription& a, } -class MeshVertexDescComparator : - public std::binary_function +struct MeshVertexDescComparator { -public: - MeshVertexDescComparator() = default; - bool operator()(const Mesh* a, const Mesh* b) const { return a->getVertexDescription() < b->getVertexDescription(); } - -private: - int ignore; }; - bool UniquifyVertices(Mesh& mesh) { diff --git a/src/tools/stardb/buildstardb.cpp b/src/tools/stardb/buildstardb.cpp index c980f45c..08b6cbc0 100644 --- a/src/tools/stardb/buildstardb.cpp +++ b/src/tools/stardb/buildstardb.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -1130,7 +1131,9 @@ int main(int argc, char* argv[]) // It may not even be necessary to sort the records, if the // HIPPARCOS catalog is strictly ordered by catalog number. I'm not // sure about this however, - random_shuffle(starIndex.begin(), starIndex.end()); + std::random_device rng; + std::mt19937 urng(rng()); + shuffle(starIndex.begin(), starIndex.end(), urng); sort(starIndex.begin(), starIndex.end(), pred); }