diff --git a/Base/Axis/Bin.h b/Base/Axis/Bin.h index 8fc0c452dc157fc26f07b99847b716f59c6e2158..ce1c3c6e5572dfe82fb516f0ddb763995f2bfc60 100644 --- a/Base/Axis/Bin.h +++ b/Base/Axis/Bin.h @@ -27,7 +27,11 @@ public: static Bin1D FromTo(double lower, double upper); static Bin1D At(double center); static Bin1D At(double center, double halfwidth); - bool operator==(const Bin1D&) const = default; + + bool operator==(const Bin1D& other) const + { + return (m_lower == other.m_lower && m_upper == other.m_upper); + } double min() const { return m_lower; } double max() const { return m_upper; } diff --git a/Base/Axis/Coordinate.h b/Base/Axis/Coordinate.h index 3bd802836de6001acca29ad4d84678af9a7c4869..b478dad47b730a2a90dab1d47cd121f79382fa2d 100644 --- a/Base/Axis/Coordinate.h +++ b/Base/Axis/Coordinate.h @@ -28,7 +28,10 @@ public: Coordinate(const std::string& label); Coordinate(const std::string& name, const std::string& unit); - bool operator==(const Coordinate& other) const = default; + bool operator==(const Coordinate& other) const + { + return (m_name == other.m_name && m_unit == other.m_unit); + } const std::string& name() const { return m_name; } const std::string& unit() const { return m_unit; } diff --git a/Base/Axis/Frame.cpp b/Base/Axis/Frame.cpp index 9b226387c57508e5a40a2e0f0f4c4195e99b99c3..c3c7b06707fd2e44a54b3e4f3027a67fbe50db23 100644 --- a/Base/Axis/Frame.cpp +++ b/Base/Axis/Frame.cpp @@ -118,7 +118,7 @@ bool Frame::operator==(const Frame& o) const if (rank() != o.rank()) return false; for (size_t k = 0; k < rank(); ++k) - if (axis(k) != o.axis(k)) + if (!(axis(k) == o.axis(k))) return false; return true; } diff --git a/Base/Axis/Scale.cpp b/Base/Axis/Scale.cpp index e64ad5525251437c35b4e595fe09a0289c264e67..f266f547e80012bf7572381171beca149b68beb8 100644 --- a/Base/Axis/Scale.cpp +++ b/Base/Axis/Scale.cpp @@ -13,16 +13,16 @@ // ************************************************************************************************ #include "Base/Axis/Scale.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Const/Units.h" #include "Base/Util/Assert.h" #include "Base/Util/StringUtil.h" #include <cmath> #include <iomanip> #include <iostream> -#include <numbers> #include <stdexcept> -using std::numbers::pi; +using PhysConsts::pi; Scale::Scale(const Coordinate& coord, const std::vector<Bin1D>& bins) : m_bins(bins) diff --git a/Base/Const/PhysicalConstants.h b/Base/Const/PhysicalConstants.h index 7e8f4975b33cba4df1bacc3c1a529b0ba9ceef94..cb5f1959175bb98f707e9fc9f2fc3577f0e56ca0 100644 --- a/Base/Const/PhysicalConstants.h +++ b/Base/Const/PhysicalConstants.h @@ -17,7 +17,11 @@ #endif // SWIG #ifndef BORNAGAIN_BASE_CONST_PHYSICALCONSTANTS_H #define BORNAGAIN_BASE_CONST_PHYSICALCONSTANTS_H +#ifdef BA_CPP20 +#include <numbers> + +#endif // BA_CPP20 //! Physical constants. namespace PhysConsts { @@ -30,6 +34,11 @@ constexpr double r_e = 2.8179403262e-15; //!< Thomson scattering length (\f$ r constexpr double gamma_n = 1.91304272; //!< \f$\gamma\f$ factor for neutron magnetic moment, //!< \f$\mu_n = \gamma \cdot \mu_N\f$ constexpr double g_factor_n = -3.82608545; //!< neutron g-factor +#ifdef BA_CPP20 +constexpr double pi = std::numbers::pi; +#else +constexpr double pi = 3.141592653589793238462643383279502884L; // OEIS: A000796 +#endif // BA_CPP20 } // namespace PhysConsts diff --git a/Base/Math/Bessel.cpp b/Base/Math/Bessel.cpp index 4c10185c72ca3938b880c5de91c34dbbe6a7edf6..6102ef5479bfd86aad44601c4c205b79f3a0e067 100644 --- a/Base/Math/Bessel.cpp +++ b/Base/Math/Bessel.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "Base/Math/Bessel.h" +#include "Base/Const/PhysicalConstants.h" #include <gsl/gsl_sf_bessel.h> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Base/Math/Functions.cpp b/Base/Math/Functions.cpp index 35ec5d1da22eb8a52d931dcb2b72e4305d53d827..8de9d740ebec7cd18367bf04f01dd14640d0ffc2 100644 --- a/Base/Math/Functions.cpp +++ b/Base/Math/Functions.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "Base/Math/Functions.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Util/Assert.h" #include <chrono> #include <cstring> @@ -20,10 +21,9 @@ #include <gsl/gsl_sf_erf.h> #include <gsl/gsl_sf_expint.h> #include <limits> -#include <numbers> #include <random> -using std::numbers::pi; +using PhysConsts::pi; // ************************************************************************************************ // Various functions diff --git a/Base/Py/PyFmt.cpp b/Base/Py/PyFmt.cpp index 95ee75072dd88a3e7acee8f19368fb200b6bde9c..4ee28a75a346ec530ecfdc0e43dc5c991e3a0227 100644 --- a/Base/Py/PyFmt.cpp +++ b/Base/Py/PyFmt.cpp @@ -13,14 +13,14 @@ // ************************************************************************************************ #include "Base/Py/PyFmt.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Const/Units.h" // printDegrees #include "Base/Math/Numeric.h" #include "Base/Util/Assert.h" #include "Base/Util/StringUtil.h" #include <iomanip> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; std::string Py::Fmt::printImportedSymbols(const std::string& code) { diff --git a/Base/Util/StringUtil.cpp b/Base/Util/StringUtil.cpp index b3e0ac33ac71a7f52eb07d72a48877888806b60b..611af544b7d3d12e8565c9b3d1b3019e0b4661c5 100644 --- a/Base/Util/StringUtil.cpp +++ b/Base/Util/StringUtil.cpp @@ -18,8 +18,11 @@ #include <cctype> #include <cerrno> #include <charconv> -#include <ranges> +#include <iterator> #include <regex> +#ifdef BA_CPP20 +#include <ranges> +#endif // BA_CPP20 //! Returns token vector obtained by splitting string at delimiters. std::vector<std::string> Base::String::split(const std::string& text, const std::string& delimiter) @@ -66,7 +69,14 @@ std::string Base::String::join(const std::vector<std::string>& joinable, const s std::string Base::String::to_lower(std::string text) { + +#ifdef BA_CPP20 std::ranges::transform(text, text.begin(), [](unsigned char c) { return std::tolower(c); }); +#else + std::transform(text.begin(), text.end(), text.begin(), + [](unsigned char c) { return std::tolower(c); }); +#endif // BA_CPP20 + return text; } diff --git a/Base/Vector/GisasDirection.cpp b/Base/Vector/GisasDirection.cpp index 0e3d1c49484748ef6e8ff682faca8763d8392924..520763cbec2611498d0b49a2ca6e449358cc0c73 100644 --- a/Base/Vector/GisasDirection.cpp +++ b/Base/Vector/GisasDirection.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "Base/Vector/GisasDirection.h" +#include "Base/Const/PhysicalConstants.h" #include <cmath> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; R3 vecOfKAlphaPhi(double _k, double _alpha, double _phi) { diff --git a/CMakeLists.txt b/CMakeLists.txt index ef434487fdf794333ceee3599424dde7469dbb33..2241aa68c145e797e38298a789e4da790993800d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,6 @@ message(STATUS "Git branch '${GIT_BRANCH}' at commit ${GIT_COMMIT}, tag: '${GIT_ include(cmake/commons/PreventInSourceBuilds) - ### Project settings project(BornAgain @@ -25,12 +24,10 @@ project(BornAgain HOMEPAGE_URL https://www.bornagainproject.org LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 20) - - ### Options # options that are on by default (switch off for accelerated builds of limited scope) +option(BA_CPP20 "Use C++20 standard" OFF) option(BORNAGAIN_PYTHON "Build with Python support" ON) option(BA_GUI "Build a graphical user interface" ON) option(BA_TIFF_SUPPORT "Tiff files read/write support" ON) @@ -102,6 +99,14 @@ if(BA_TESTS AND NOT BA_PY_PACK) message(FATAL_ERROR "Tests need the BA Python package, hence BA_PY_PACK must be ON.") endif() +### set C++ standard + +if(BA_CPP20) + set(CMAKE_CXX_STANDARD 20) +else() + set(CMAKE_CXX_STANDARD 17) +endif() + ### Generator type (Release|Debug) # Show info about generator type; set CMAKE_BUILD_TYPE if not given diff --git a/Device/Beam/Beam.cpp b/Device/Beam/Beam.cpp index 739018a992005b5850d601241811a30a279e9b3b..7a498ceaeedc51e971c1431c0e569b18f4570c6a 100644 --- a/Device/Beam/Beam.cpp +++ b/Device/Beam/Beam.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "Device/Beam/Beam.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Spin/SpinMatrix.h" #include "Base/Util/Assert.h" #include "Base/Vector/GisasDirection.h" #include "Device/Beam/IFootprint.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; //... Constructors, destructors: diff --git a/Device/Beam/FootprintGauss.cpp b/Device/Beam/FootprintGauss.cpp index af49e838dce0eedd9f7708b5a338acff49d637d9..c2c1aae6bab7a7079e304ffee167c7a14cfbf5b8 100644 --- a/Device/Beam/FootprintGauss.cpp +++ b/Device/Beam/FootprintGauss.cpp @@ -13,11 +13,11 @@ // ************************************************************************************************ #include "Device/Beam/FootprintGauss.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Functions.h" #include "Base/Util/Assert.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; FootprintGauss::FootprintGauss(const std::vector<double> P) : IFootprint(P) diff --git a/Device/Beam/FootprintSquare.cpp b/Device/Beam/FootprintSquare.cpp index 75d98aaf8b0426ff48ff69c7235ba39e968441bc..a7fe7828e82c408e11dbe547522c75e087abe3f9 100644 --- a/Device/Beam/FootprintSquare.cpp +++ b/Device/Beam/FootprintSquare.cpp @@ -13,12 +13,12 @@ // ************************************************************************************************ #include "Device/Beam/FootprintSquare.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Util/Assert.h" #include <algorithm> #include <cmath> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; FootprintSquare::FootprintSquare(const std::vector<double> P) : IFootprint(P) diff --git a/Device/Detector/SphericalDetector.cpp b/Device/Detector/SphericalDetector.cpp index 3e816d9b31618e67f04fd75d4e281f1168606d12..10e10e342079b95a8b2ae6b9e3315b6be6618862 100644 --- a/Device/Detector/SphericalDetector.cpp +++ b/Device/Detector/SphericalDetector.cpp @@ -17,12 +17,12 @@ #include "Base/Axis/MakeScale.h" #include "Base/Axis/Pixel.h" #include "Base/Axis/Scale.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Util/Assert.h" #include "Device/Beam/Beam.h" #include "Device/Resolution/IDetectorResolution.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; SphericalDetector::SphericalDetector(size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min, double alpha_max) diff --git a/Device/IO/ReadReflectometry.cpp b/Device/IO/ReadReflectometry.cpp index 333f9bcaeca0b195ffb41376cce909cf06e3f8cd..6e85ad3455254c3161318802516edef826a4f981 100644 --- a/Device/IO/ReadReflectometry.cpp +++ b/Device/IO/ReadReflectometry.cpp @@ -14,6 +14,7 @@ #include "Device/IO/ReadReflectometry.h" #include "Base/Axis/MakeScale.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Numeric.h" #include "Base/Util/Assert.h" #include "Base/Util/StringUtil.h" @@ -21,13 +22,12 @@ #include "Device/IO/ImportSettings.h" #include <algorithm> #include <map> -#include <numbers> using Base::String::split; using Base::String::to_double; using Base::String::to_int; using Base::String::trim; -using std::numbers::pi; +using PhysConsts::pi; Datafield Util::RW::readReflectometryTable(std::istream& s, const ImportSettings1D& p) { diff --git a/Device/IO/ReadWrite2DTable.cpp b/Device/IO/ReadWrite2DTable.cpp index 3d95d18a79bbb0d934f1ce79de243983d34ecaef..b7a939fcd2aeadb2eecce77d3cd3dc146123858e 100644 --- a/Device/IO/ReadWrite2DTable.cpp +++ b/Device/IO/ReadWrite2DTable.cpp @@ -15,6 +15,7 @@ #include "Device/IO/ReadWrite2DTable.h" #include "Base/Axis/MakeScale.h" #include "Base/Axis/Scale.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Numeric.h" #include "Base/Util/Assert.h" #include "Base/Util/StringUtil.h" @@ -22,11 +23,10 @@ #include "Device/Data/Datafield.h" #include "Device/IO/ImportSettings.h" #include <algorithm> -#include <numbers> #include <string> #include <vector> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/GUI/Model/Sim/InstrumentItems.cpp b/GUI/Model/Sim/InstrumentItems.cpp index f81b0ada1d8e1de5d2dc26f61fd3a4f6ecf98cb0..8bd3f04bd77267012dee0052bcb24f6f99491a17 100644 --- a/GUI/Model/Sim/InstrumentItems.cpp +++ b/GUI/Model/Sim/InstrumentItems.cpp @@ -16,6 +16,7 @@ #include "Base/Axis/Frame.h" #include "Base/Axis/MakeScale.h" #include "Base/Axis/Scale.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Const/Units.h" #include "Base/Util/Assert.h" #include "Device/Beam/Beam.h" @@ -42,9 +43,8 @@ #include "Sim/Scan/AlphaScan.h" #include "Sim/Simulation/includeSimulations.h" #include <QUuid> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { namespace Tag { diff --git a/Img3D/Mesh/Column.cpp b/Img3D/Mesh/Column.cpp index 8e204504347ce8c6bbb7d5ff9554215227fc1cf4..5d99a3163f7856184aaee388c2e451df2f1ada80 100644 --- a/Img3D/Mesh/Column.cpp +++ b/Img3D/Mesh/Column.cpp @@ -12,11 +12,11 @@ // // ************************************************************************************************ +#include "Base/Const/PhysicalConstants.h" #include "Base/Util/Assert.h" #include "Img3D/Model/Geometry.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace Img3D { diff --git a/Img3D/Mesh/Cuboctahedron.cpp b/Img3D/Mesh/Cuboctahedron.cpp index b5e6eed0ff44fd2ca31b7b308c83b8638ef75101..f2df280cf4d9f425831ee9b3479d25e5bdb38df3 100644 --- a/Img3D/Mesh/Cuboctahedron.cpp +++ b/Img3D/Mesh/Cuboctahedron.cpp @@ -12,11 +12,11 @@ // // ************************************************************************************************ +#include "Base/Const/PhysicalConstants.h" #include "Base/Util/Assert.h" #include "Img3D/Model/Geometry.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace Img3D { diff --git a/Img3D/Mesh/Ripple.cpp b/Img3D/Mesh/Ripple.cpp index 7397299d2e2da7e83f380bb44680e8b53b737700..f05aacfa147611583962ce680dd3046acc3056fc 100644 --- a/Img3D/Mesh/Ripple.cpp +++ b/Img3D/Mesh/Ripple.cpp @@ -12,11 +12,11 @@ // // ************************************************************************************************ +#include "Base/Const/PhysicalConstants.h" #include "Base/Util/Assert.h" #include "Img3D/Model/Geometry.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace Img3D { diff --git a/Img3D/Mesh/Sphere.cpp b/Img3D/Mesh/Sphere.cpp index 8df5420f8553f7602c8b5073772616c82b4886ac..1e831fffcd2028a9f1f89b6cd99aafe82fd2d0cc 100644 --- a/Img3D/Mesh/Sphere.cpp +++ b/Img3D/Mesh/Sphere.cpp @@ -12,11 +12,11 @@ // // ************************************************************************************************ +#include "Base/Const/PhysicalConstants.h" #include "Base/Util/Assert.h" #include "Img3D/Model/Geometry.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace Img3D { diff --git a/Img3D/Model/Particles.cpp b/Img3D/Model/Particles.cpp index da75353644fc836b95d26fe91cbd79a77a11e09a..7851303a2b2caf253430244bb5e43ebea46266c7 100644 --- a/Img3D/Model/Particles.cpp +++ b/Img3D/Model/Particles.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "Img3D/Model/Particles.h" -#include <numbers> +#include "Base/Const/PhysicalConstants.h" namespace Img3D { @@ -56,7 +56,7 @@ void PlotParticle::addExtrinsicRotation(F3 rotateExtrinsic) namespace Particles { -static float const pi = std::numbers::pi_v<float>; +static float const pi = static_cast<float>(PhysConsts::pi); static float const sqrt2f = std::sqrt(2.f); static float const sqrt3f = std::sqrt(3.f); diff --git a/Img3D/Model/PlottableBody.cpp b/Img3D/Model/PlottableBody.cpp index b5a585bffe4f7d16dfea7ef4f85ea34cd03ee154..c35fdb421edab2ac1ab39c07349c2238067e3e20 100644 --- a/Img3D/Model/PlottableBody.cpp +++ b/Img3D/Model/PlottableBody.cpp @@ -13,11 +13,11 @@ // ************************************************************************************************ #include "Img3D/Model/PlottableBody.h" +#include "Base/Const/PhysicalConstants.h" #include "Img3D/Model/Geometry.h" #include "Img3D/Model/GeometryStore.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Param/Distrib/Distributions.cpp b/Param/Distrib/Distributions.cpp index c90658435d743505aa5291e5d8285d0a39754d75..4456a0b18eb15728fb667016849911370b5602eb 100644 --- a/Param/Distrib/Distributions.cpp +++ b/Param/Distrib/Distributions.cpp @@ -13,15 +13,15 @@ // ************************************************************************************************ #include "Param/Distrib/Distributions.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Py/PyFmt.h" #include "Base/Util/Assert.h" #include "Param/Distrib/ParameterSample.h" #include <cmath> #include <limits> -#include <numbers> #include <sstream> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Resample/Element/DiffuseElement.cpp b/Resample/Element/DiffuseElement.cpp index 8ad0089a0234c7701c8bd9688051e14c5db7d4ba..750eb49673a9458d494adb32d5cefce3c92d46bc 100644 --- a/Resample/Element/DiffuseElement.cpp +++ b/Resample/Element/DiffuseElement.cpp @@ -14,12 +14,12 @@ #include "Resample/Element/DiffuseElement.h" #include "Base/Axis/Pixel.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Vector/GisasDirection.h" #include "Base/Vector/WavevectorInfo.h" #include "Resample/Flux/IFlux.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; DiffuseElement::DiffuseElement(double wavelength, double alpha_i, double phi_i, const Pixel* const pixel, const SpinMatrix& polarizer, diff --git a/Resample/Particle/ReMesocrystal.cpp b/Resample/Particle/ReMesocrystal.cpp index c9535a2292992e717b4ff8e55628334d0401413b..19e6b53ae91262c3304af0e3519a2acda95a8945 100644 --- a/Resample/Particle/ReMesocrystal.cpp +++ b/Resample/Particle/ReMesocrystal.cpp @@ -13,15 +13,15 @@ // ************************************************************************************************ #include "Resample/Particle/ReMesocrystal.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Numeric.h" #include "Base/Spin/SpinMatrix.h" #include "Base/Type/Span.h" #include "Base/Util/Assert.h" #include "Base/Vector/WavevectorInfo.h" #include "Resample/Particle/ReParticle.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; ReMesocrystal::ReMesocrystal(const std::optional<size_t>& i_layer, const Lattice3D& lattice, const IReParticle& basis, const ReParticle& outer_shape, diff --git a/Resample/Processed/Slicer.cpp b/Resample/Processed/Slicer.cpp index 106c9d6ebf9eb0426caba3f1857d4ffdb2b84598..c528c68086739624b7a1c599e29fe4db331394bd 100644 --- a/Resample/Processed/Slicer.cpp +++ b/Resample/Processed/Slicer.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "Resample/Processed/Slicer.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Functions.h" #include "Base/Type/Span.h" #include "Base/Util/Assert.h" @@ -29,9 +30,8 @@ #include "Sample/Particle/Mesocrystal.h" #include "Sample/Particle/Particle.h" #include "Sample/Scattering/Rotations.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Resample/Slice/KzComputation.cpp b/Resample/Slice/KzComputation.cpp index f0814be7f3b566e8cd9284c31d41bacdba2ff607..ddc4e6b69b0439ed997c75890c47a6467cccc0ec 100644 --- a/Resample/Slice/KzComputation.cpp +++ b/Resample/Slice/KzComputation.cpp @@ -13,12 +13,12 @@ // ************************************************************************************************ #include "Resample/Slice/KzComputation.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Const/Units.h" #include "Base/Util/Assert.h" #include "Resample/Slice/SliceStack.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Resample/Slice/ProfileHelper.cpp b/Resample/Slice/ProfileHelper.cpp index 0d3701625f4850180f9bb007f75ab968048aef1a..755da8568638ebb03bd32664c77a98c3d40cc13f 100644 --- a/Resample/Slice/ProfileHelper.cpp +++ b/Resample/Slice/ProfileHelper.cpp @@ -13,12 +13,12 @@ // ************************************************************************************************ #include "Resample/Slice/ProfileHelper.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Functions.h" #include "Base/Util/Assert.h" #include "Sample/Interface/LayerRoughness.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Resample/Slice/Slice.cpp b/Resample/Slice/Slice.cpp index 6200188998a7dd8d5335659b7bad8b584d5ce74e..ed57b42fecc66f9085cfc21e1c0350c08849fadd 100644 --- a/Resample/Slice/Slice.cpp +++ b/Resample/Slice/Slice.cpp @@ -13,14 +13,14 @@ // ************************************************************************************************ #include "Resample/Slice/Slice.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Spin/SpinMatrix.h" #include "Resample/Slice/SliceStack.h" #include "Sample/Interface/LayerRoughness.h" #include "Sample/Material/MaterialUtil.h" -#include <numbers> #include <utility> -using std::numbers::pi; +using PhysConsts::pi; Slice::Slice(const ZLimits& zRange, const Material& material, const R3& B_field, const LayerRoughness* const roughness, double rms) diff --git a/Resample/Specular/ComputeFluxMagnetic.cpp b/Resample/Specular/ComputeFluxMagnetic.cpp index 1d02e028171392ef4bf3455d5c7896a592ae960c..307b63160b630e44acb9ba703d03a0757f9ac4cd 100644 --- a/Resample/Specular/ComputeFluxMagnetic.cpp +++ b/Resample/Specular/ComputeFluxMagnetic.cpp @@ -22,9 +22,8 @@ #include "Resample/Slice/SliceStack.h" #include "Sample/Interface/LayerRoughness.h" #include <algorithm> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Resample/Specular/ComputeFluxScalar.cpp b/Resample/Specular/ComputeFluxScalar.cpp index 07025f78b41a347e7ad24f0b758d1a3c0f492f08..8a87e7574033527ff1e8ce54b4f111576e873c4f 100644 --- a/Resample/Specular/ComputeFluxScalar.cpp +++ b/Resample/Specular/ComputeFluxScalar.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "Resample/Specular/ComputeFluxScalar.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Functions.h" #include "Base/Util/Assert.h" #include "Resample/Flux/ScalarFlux.h" @@ -20,9 +21,8 @@ #include "Resample/Slice/SliceStack.h" #include "Sample/Interface/LayerRoughness.h" #include "Sample/Multilayer/Layer.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Sample/Aggregate/Interference2DSuperLattice.cpp b/Sample/Aggregate/Interference2DSuperLattice.cpp index 2a91e9f75a8b55b12080e839f6686be1c42dc8de..faae0758e4d02de3f13ddb25733377b0fc1ad5ff 100644 --- a/Sample/Aggregate/Interference2DSuperLattice.cpp +++ b/Sample/Aggregate/Interference2DSuperLattice.cpp @@ -13,14 +13,14 @@ // ************************************************************************************************ #include "Sample/Aggregate/Interference2DSuperLattice.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Functions.h" #include "Base/Math/IntegratorGK.h" #include "Base/Util/Assert.h" #include "Sample/Aggregate/InterferenceNone.h" #include <limits> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; Interference2DSuperLattice::Interference2DSuperLattice(const Lattice2D& lattice, unsigned size_1, unsigned size_2) diff --git a/Sample/Aggregate/InterferenceFinite2DLattice.cpp b/Sample/Aggregate/InterferenceFinite2DLattice.cpp index 25cec2d7dc763919d50ad2f2a1be46886cc4b77d..27f3751db59e0b28d2bde981c806e6553d25756e 100644 --- a/Sample/Aggregate/InterferenceFinite2DLattice.cpp +++ b/Sample/Aggregate/InterferenceFinite2DLattice.cpp @@ -13,14 +13,14 @@ // ************************************************************************************************ #include "Sample/Aggregate/InterferenceFinite2DLattice.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Functions.h" #include "Base/Math/IntegratorGK.h" #include "Base/Util/Assert.h" #include <limits> -#include <numbers> using Math::Laue; -using std::numbers::pi; +using PhysConsts::pi; //! Constructor of two-dimensional finite lattice interference function. //! @param lattice: object specifying a 2d lattice structure diff --git a/Sample/Aggregate/InterferenceHardDisk.cpp b/Sample/Aggregate/InterferenceHardDisk.cpp index ceac7cdc503c4ac0cad98c27518f0c8c416433d6..cf7f56edfd35ebb9ce4d3ed66d62d4b527b4063f 100644 --- a/Sample/Aggregate/InterferenceHardDisk.cpp +++ b/Sample/Aggregate/InterferenceHardDisk.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "Sample/Aggregate/InterferenceHardDisk.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Bessel.h" #include "Base/Math/IntegratorGK.h" #include "Base/Util/Assert.h" #include <cmath> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Sample/Correlation/IDistribution1DSampler.cpp b/Sample/Correlation/IDistribution1DSampler.cpp index 272b2e7b1faead97f4e101341e5a09e90c6c3f2c..42f94df0a8ec5effe41d787fed24bbfe88574936 100644 --- a/Sample/Correlation/IDistribution1DSampler.cpp +++ b/Sample/Correlation/IDistribution1DSampler.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "Sample/Correlation/IDistribution1DSampler.h" -#include <numbers> +#include "Base/Const/PhysicalConstants.h" #include <random> -using std::numbers::pi; +using PhysConsts::pi; IDistribution1DSampler::~IDistribution1DSampler() = default; diff --git a/Sample/Correlation/IDistribution2DSampler.cpp b/Sample/Correlation/IDistribution2DSampler.cpp index dc91bc406426d6d36ac386271f48029f2eaee6bd..18692364724e9eb9bfb70592553f3c3c66b4e48f 100644 --- a/Sample/Correlation/IDistribution2DSampler.cpp +++ b/Sample/Correlation/IDistribution2DSampler.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "Sample/Correlation/IDistribution2DSampler.h" -#include <numbers> +#include "Base/Const/PhysicalConstants.h" #include <random> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Sample/Correlation/IPeakShape.cpp b/Sample/Correlation/IPeakShape.cpp index d66194dfb07004f4b7092b663d7f250b39a78288..d498ff020e0cf7ac018457f42f9af037f0e00e90 100644 --- a/Sample/Correlation/IPeakShape.cpp +++ b/Sample/Correlation/IPeakShape.cpp @@ -13,12 +13,12 @@ // ************************************************************************************************ #include "Sample/Correlation/IPeakShape.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Bessel.h" #include "Base/Math/IntegratorGK.h" #include <limits> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Sample/Correlation/Profiles1D.cpp b/Sample/Correlation/Profiles1D.cpp index 9137de3516988d227bc299d3223567f3a9d57ce8..9612e7d82c8959531270ec28e8b2531ca597bb7e 100644 --- a/Sample/Correlation/Profiles1D.cpp +++ b/Sample/Correlation/Profiles1D.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "Sample/Correlation/Profiles1D.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Functions.h" #include "Base/Py/PyFmt.h" #include "Base/Util/Assert.h" #include <limits> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Sample/Correlation/Profiles2D.h b/Sample/Correlation/Profiles2D.h index bad379a95bcdf24201d760d00d90195c8a9689b6..4d5b09dfd5827cec9ff69d5b7ea20c3fddc006d0 100644 --- a/Sample/Correlation/Profiles2D.h +++ b/Sample/Correlation/Profiles2D.h @@ -15,15 +15,15 @@ #ifndef BORNAGAIN_SAMPLE_CORRELATION_PROFILES2D_H #define BORNAGAIN_SAMPLE_CORRELATION_PROFILES2D_H +#include "Base/Const/PhysicalConstants.h" #include "Base/Type/ICloneable.h" #include "Param/Node/INode.h" -#include <numbers> #ifndef SWIG #include "Sample/Correlation/IDistribution2DSampler.h" #endif // SWIG -using std::numbers::pi; +using PhysConsts::pi; //! Interface for two-dimensional distributions in Fourier space. diff --git a/Sample/HardParticle/Cone.cpp b/Sample/HardParticle/Cone.cpp index 77b0e8f8ee6ec8214f93d71b39b0594c41c9fbb8..f1afe44f5848cd9108703f1ed2d8ac9d23768ecf 100644 --- a/Sample/HardParticle/Cone.cpp +++ b/Sample/HardParticle/Cone.cpp @@ -13,15 +13,15 @@ // ************************************************************************************************ #include "Sample/HardParticle/Cone.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Bessel.h" #include "Base/Math/Functions.h" #include "Base/Math/IntegratorGK.h" #include "Base/Util/Assert.h" #include "Sample/Shape/DoubleEllipse.h" #include <limits> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; Cone::Cone(const std::vector<double> P) : IFormfactor(P) diff --git a/Sample/HardParticle/Cylinder.cpp b/Sample/HardParticle/Cylinder.cpp index 5fa999a0b0adb813e9ad4472ef453c04a924f4fa..264dffac5487f0fc3b60870b019f885a378ebb47 100644 --- a/Sample/HardParticle/Cylinder.cpp +++ b/Sample/HardParticle/Cylinder.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "Sample/HardParticle/Cylinder.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Bessel.h" #include "Base/Math/Functions.h" #include "Base/Util/Assert.h" #include "Sample/Shape/DoubleEllipse.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; Cylinder::Cylinder(const std::vector<double> P) : IFormfactor(P) diff --git a/Sample/HardParticle/EllipsoidalCylinder.cpp b/Sample/HardParticle/EllipsoidalCylinder.cpp index cd8ff673e7f8221e713a54e6b0eea11f4873cb21..61d096b63960877aaacadf678cb41ae1b5e12625 100644 --- a/Sample/HardParticle/EllipsoidalCylinder.cpp +++ b/Sample/HardParticle/EllipsoidalCylinder.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "Sample/HardParticle/EllipsoidalCylinder.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Bessel.h" #include "Base/Math/Functions.h" #include "Base/Util/Assert.h" #include "Sample/Shape/DoubleEllipse.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; EllipsoidalCylinder::EllipsoidalCylinder(const std::vector<double> P) : IFormfactor(P) diff --git a/Sample/HardParticle/HemiEllipsoid.cpp b/Sample/HardParticle/HemiEllipsoid.cpp index 84ca9dfbc58f76cfa3386c699289a54622408b95..d9b907d80bdf3aa150fb9b48c81ced42294d3051 100644 --- a/Sample/HardParticle/HemiEllipsoid.cpp +++ b/Sample/HardParticle/HemiEllipsoid.cpp @@ -13,14 +13,14 @@ // ************************************************************************************************ #include "Sample/HardParticle/HemiEllipsoid.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Bessel.h" #include "Base/Math/IntegratorGK.h" #include "Base/Util/Assert.h" #include "Sample/Shape/TruncatedEllipsoidNet.h" #include <limits> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; HemiEllipsoid::HemiEllipsoid(const std::vector<double> P) : IFormfactor(P) diff --git a/Sample/HardParticle/HorizontalCylinder.cpp b/Sample/HardParticle/HorizontalCylinder.cpp index e54d9441ec591f73e5ecc246c417afe0d150319b..df0066f6afb3d90de5ad431f629ced92a5281e16 100644 --- a/Sample/HardParticle/HorizontalCylinder.cpp +++ b/Sample/HardParticle/HorizontalCylinder.cpp @@ -13,14 +13,14 @@ // ************************************************************************************************ #include "Sample/HardParticle/HorizontalCylinder.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Bessel.h" #include "Base/Math/Functions.h" #include "Base/Math/IntegratorGK.h" #include "Base/Util/Assert.h" #include "Sample/Shape/DoubleEllipse.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; HorizontalCylinder::HorizontalCylinder(const std::vector<double> P) : IFormfactor(P) diff --git a/Sample/HardParticle/Polyhedra.cpp b/Sample/HardParticle/Polyhedra.cpp index 87cab965cc986730d20910a30be773e4c09c2b2c..b121d97a8768d3623de7c3586bd78df5e3931a7f 100644 --- a/Sample/HardParticle/Polyhedra.cpp +++ b/Sample/HardParticle/Polyhedra.cpp @@ -13,11 +13,11 @@ // ************************************************************************************************ #include "Sample/HardParticle/Polyhedra.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Const/Units.h" #include <ff/Make.h> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; // ************************************************************************************************ // Prisms @@ -356,7 +356,7 @@ bool Pyramid6::contains(const R3& position) const / std::sqrt(std::pow(position.x(), 2) + std::pow(position.y(), 2)))); int c = static_cast<int>(theta_prime / 60); // multiplication constant double theta = Units::deg2rad(theta_prime - c * 60); - double k_z = l_z / (std::cos(theta) + std::sin(theta) / std::tan(std::numbers::pi / 3)); + double k_z = l_z / (std::cos(theta) + std::sin(theta) / std::tan(pi / 3)); if (std::pow(position.x(), 2) + std::pow(position.y(), 2) <= std::pow(k_z, 2)) return true; diff --git a/Sample/HardParticle/Ripples.cpp b/Sample/HardParticle/Ripples.cpp index e93c5b7fa678c863a1d6de2ea180ed74646da3de..289b31508182f1f9d906c09525256f1c69d59c93 100644 --- a/Sample/HardParticle/Ripples.cpp +++ b/Sample/HardParticle/Ripples.cpp @@ -13,11 +13,11 @@ // ************************************************************************************************ #include "Sample/HardParticle/Ripples.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Functions.h" #include "Base/Math/IntegratorGK.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; complex_t ripples::factor_x_box(complex_t q, double l) { diff --git a/Sample/HardParticle/Spheroid.cpp b/Sample/HardParticle/Spheroid.cpp index c695a88bd6ab7f911eef9440a7eae618b020c872..20e1e93487a16e550743334261a169e8de8678eb 100644 --- a/Sample/HardParticle/Spheroid.cpp +++ b/Sample/HardParticle/Spheroid.cpp @@ -13,14 +13,14 @@ // ************************************************************************************************ #include "Sample/HardParticle/Spheroid.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Functions.h" #include "Base/Util/Assert.h" #include "Sample/HardParticle/TruncatedSpheroid.h" #include "Sample/Shape/TruncatedEllipsoidNet.h" #include <limits> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; Spheroid::Spheroid(const std::vector<double> P) : IFormfactor(P) diff --git a/Sample/HardParticle/TruncatedSphere.cpp b/Sample/HardParticle/TruncatedSphere.cpp index 1bc587642a477f265b4203a25461004ef0d58316..7454cb7e46c1749540aada5e3b88c8cb23a7e845 100644 --- a/Sample/HardParticle/TruncatedSphere.cpp +++ b/Sample/HardParticle/TruncatedSphere.cpp @@ -13,14 +13,14 @@ // ************************************************************************************************ #include "Sample/HardParticle/TruncatedSphere.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Bessel.h" #include "Base/Math/IntegratorGK.h" #include "Base/Util/Assert.h" #include "Sample/Shape/TruncatedEllipsoidNet.h" #include <limits> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; TruncatedSphere::TruncatedSphere(const std::vector<double> P) : IFormfactor(P) diff --git a/Sample/HardParticle/TruncatedSpheroid.cpp b/Sample/HardParticle/TruncatedSpheroid.cpp index 0434e55f9b165359fcb442430fa6af2846aa5812..bcaacfad521dc49dc61b82de5a3db6b56c0d3e07 100644 --- a/Sample/HardParticle/TruncatedSpheroid.cpp +++ b/Sample/HardParticle/TruncatedSpheroid.cpp @@ -13,14 +13,14 @@ // ************************************************************************************************ #include "Sample/HardParticle/TruncatedSpheroid.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Bessel.h" #include "Base/Math/IntegratorGK.h" #include "Base/Util/Assert.h" #include "Sample/Shape/TruncatedEllipsoidNet.h" #include <limits> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; TruncatedSpheroid::TruncatedSpheroid(const std::vector<double> P) : IFormfactor(P) diff --git a/Sample/Interface/AutocorrelationModels.cpp b/Sample/Interface/AutocorrelationModels.cpp index 137718499ea4d38b75989f8199eb21b4d1e5e601..fc09008e629a3f3ebf4bca8b29825561dfaecbb7 100644 --- a/Sample/Interface/AutocorrelationModels.cpp +++ b/Sample/Interface/AutocorrelationModels.cpp @@ -13,12 +13,12 @@ // ************************************************************************************************ #include "Sample/Interface/AutocorrelationModels.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Py/PyFmt.h" #include "Base/Util/Assert.h" #include <gsl/gsl_sf_bessel.h> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; AutocorrelationModel::AutocorrelationModel(double maxSpatFrequency) : m_max_spatial_frequency(maxSpatFrequency) diff --git a/Sample/Interface/CrosscorrelationModels.cpp b/Sample/Interface/CrosscorrelationModels.cpp index c20445ea491d627bebaad2ed66359abd67059481..db2202e75d85a7bcdd2584e8114bb04a48c0dfc3 100644 --- a/Sample/Interface/CrosscorrelationModels.cpp +++ b/Sample/Interface/CrosscorrelationModels.cpp @@ -13,12 +13,12 @@ // ************************************************************************************************ #include "Sample/Interface/CrosscorrelationModels.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Py/PyFmt.h" #include "Base/Util/Assert.h" #include <cmath> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; SpatialFrequencyCrosscorrelation::SpatialFrequencyCrosscorrelation(double base_crosscorr_depth, double base_frequency, diff --git a/Sample/Interface/InterlayerModels.cpp b/Sample/Interface/InterlayerModels.cpp index e21b9ae36aabea8dedc44c3448e5ef687a4a6626..9fb3d06050136040a465215318b163631c9b4fb1 100644 --- a/Sample/Interface/InterlayerModels.cpp +++ b/Sample/Interface/InterlayerModels.cpp @@ -13,12 +13,12 @@ // ************************************************************************************************ #include "Sample/Interface/InterlayerModels.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Functions.h" #include "Base/Util/Assert.h" #include <cmath> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { const double tanh_prefactor = pi / 2. / std::sqrt(3); diff --git a/Sample/Interface/RoughnessMap.cpp b/Sample/Interface/RoughnessMap.cpp index 527d4ca98263a9a8b71afe7d26e59701cad0b37c..bc89154d8daf30c8b8edf7deafa2f8e40d647674 100644 --- a/Sample/Interface/RoughnessMap.cpp +++ b/Sample/Interface/RoughnessMap.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "Sample/Interface/RoughnessMap.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Util/Assert.h" #include "Sample/Interface/LayerInterface.h" #include "Sample/Interface/LayerRoughness.h" #include <algorithm> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Sample/Lattice/ISelectionRule.cpp b/Sample/Lattice/ISelectionRule.cpp index e276bd34a3b3465f77c581ab98b0b2bed7bc1f02..402b2f6d6cf82d193133976aed51fc520a2aeb2d 100644 --- a/Sample/Lattice/ISelectionRule.cpp +++ b/Sample/Lattice/ISelectionRule.cpp @@ -38,3 +38,8 @@ bool SimpleSelectionRule::isEqualTo(const ISelectionRule& isr) const return *this == *sr; return false; } + +bool SimpleSelectionRule::operator==(const SimpleSelectionRule& other) const +{ + return (m_a == other.m_a && m_b == other.m_b && m_c == other.m_c && m_mod == other.m_mod); +} diff --git a/Sample/Lattice/ISelectionRule.h b/Sample/Lattice/ISelectionRule.h index 446480d9d7275da555c5739b384932081a346f9e..220e9647c8f5560bbfd8636a6ba44af44502b410 100644 --- a/Sample/Lattice/ISelectionRule.h +++ b/Sample/Lattice/ISelectionRule.h @@ -29,7 +29,7 @@ public: virtual bool isEqualTo(const ISelectionRule& isr) const = 0; - bool operator==(const ISelectionRule&) const = default; + bool operator==(const ISelectionRule&) const { return false; } }; //! Selection rule (v*q)%modulus!=0, defined by vector v(a,b,c) and modulus. @@ -45,7 +45,7 @@ public: bool isEqualTo(const ISelectionRule& isr) const override; - bool operator==(const SimpleSelectionRule&) const = default; + bool operator==(const SimpleSelectionRule& other) const; private: int m_a, m_b, m_c; diff --git a/Sample/Lattice/Lattice2D.cpp b/Sample/Lattice/Lattice2D.cpp index ad66e626708c5fa0b7af9d84bfab1d9726e5f0d7..9e85c26977691256a4787b088d4706c91b5403fe 100644 --- a/Sample/Lattice/Lattice2D.cpp +++ b/Sample/Lattice/Lattice2D.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "Sample/Lattice/Lattice2D.h" +#include "Base/Const/PhysicalConstants.h" #include <cmath> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; // ************************************************************************************************ // class Lattice2D diff --git a/Sample/Lattice/Lattice3D.cpp b/Sample/Lattice/Lattice3D.cpp index d1fd3b39d617b60d51061537852288aa4c19a328..5600fe75fb7d01a07a76188cd284116893ef713b 100644 --- a/Sample/Lattice/Lattice3D.cpp +++ b/Sample/Lattice/Lattice3D.cpp @@ -13,11 +13,11 @@ // ************************************************************************************************ #include "Sample/Lattice/Lattice3D.h" +#include "Base/Const/PhysicalConstants.h" #include "Sample/Lattice/ISelectionRule.h" #include <gsl/gsl_linalg.h> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; Lattice3D::Lattice3D(const R3 a, const R3 b, const R3 c) : m_a(a) diff --git a/Sample/LibFF/SomeFormfactor.cpp b/Sample/LibFF/SomeFormfactor.cpp index 84a51fd60dab78427d7f277f22190c24daa3dbac..322f6d5eee818b067a4995afc4e606fd7530715e 100644 --- a/Sample/LibFF/SomeFormfactor.cpp +++ b/Sample/LibFF/SomeFormfactor.cpp @@ -13,9 +13,9 @@ // ************************************************************************************************ #include "Sample/LibFF/SomeFormfactor.h" -#include <numbers> +#include "Base/Const/PhysicalConstants.h" -using std::numbers::pi; +using PhysConsts::pi; //! Returns the form factor of a sphere of radius R. //! diff --git a/Sample/Material/MaterialBySLDImpl.cpp b/Sample/Material/MaterialBySLDImpl.cpp index f158a882e936afd98278f0c9bd3d4e454edfe362..65c213d04d862775e82ae2b0bcab98e30dee7511 100644 --- a/Sample/Material/MaterialBySLDImpl.cpp +++ b/Sample/Material/MaterialBySLDImpl.cpp @@ -13,12 +13,12 @@ // ************************************************************************************************ #include "Sample/Material/MaterialBySLDImpl.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Const/Units.h" #include "Base/Vector/WavevectorInfo.h" -#include <numbers> #include <sstream> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Sample/Material/RefractiveMaterialImpl.cpp b/Sample/Material/RefractiveMaterialImpl.cpp index ca5eea00c46f1028f0a8bdf3401b4ed6ce03d8c2..d3f5b5e1592592ec6f16f0f76d6e3cb4b984cf9c 100644 --- a/Sample/Material/RefractiveMaterialImpl.cpp +++ b/Sample/Material/RefractiveMaterialImpl.cpp @@ -13,11 +13,11 @@ // ************************************************************************************************ #include "Sample/Material/RefractiveMaterialImpl.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Vector/WavevectorInfo.h" -#include <numbers> #include <sstream> -using std::numbers::pi; +using PhysConsts::pi; RefractiveMaterialImpl::RefractiveMaterialImpl(const std::string& name, double delta, double beta, R3 magnetization) diff --git a/Sample/Multilayer/MultiLayer.cpp b/Sample/Multilayer/MultiLayer.cpp index 58ef4d8e55d539b0a2b0ac94a196623232b2682f..ae46086b7f0eccf2f87926f10f2a481e2c565799 100644 --- a/Sample/Multilayer/MultiLayer.cpp +++ b/Sample/Multilayer/MultiLayer.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "Sample/Multilayer/MultiLayer.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/IntegratorGK.h" #include "Base/Util/Assert.h" #include "Base/Util/StringUtil.h" @@ -21,9 +22,8 @@ #include "Sample/Interface/LayerRoughness.h" #include "Sample/Material/MaterialUtil.h" #include "Sample/Multilayer/Layer.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; MultiLayer::MultiLayer() { diff --git a/Sample/Shape/IShape3D.cpp b/Sample/Shape/IShape3D.cpp index 166b75742e5c96715d26b1c96663ab71fc52871a..f9d63b1943ce47e3e7abfe3ce135f8be0a3a9192 100644 --- a/Sample/Shape/IShape3D.cpp +++ b/Sample/Shape/IShape3D.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "Sample/Shape/IShape3D.h" +#include "Base/Const/PhysicalConstants.h" #include <cmath> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; // Value of 24 ensures that real points stick out of the convex hull at most // 1% of the radius diff --git a/Sample/Shape/RippleCosineNet.cpp b/Sample/Shape/RippleCosineNet.cpp index 069de336cefa4f73dc4378db063ac50ebfbae8e5..47c587158c1041db1e7261ea6b726a1305b8c47c 100644 --- a/Sample/Shape/RippleCosineNet.cpp +++ b/Sample/Shape/RippleCosineNet.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "Sample/Shape/RippleCosineNet.h" +#include "Base/Const/PhysicalConstants.h" #include <cmath> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; RippleCosineNet::RippleCosineNet(double length, double width, double height) { diff --git a/Sample/SoftParticle/Gauss.cpp b/Sample/SoftParticle/Gauss.cpp index 1d0afeb70c7ef6dd0e708513610e34a74e5a08b8..58d0d040481ad7e7012ee403516911dad09ec9de 100644 --- a/Sample/SoftParticle/Gauss.cpp +++ b/Sample/SoftParticle/Gauss.cpp @@ -13,13 +13,13 @@ // ************************************************************************************************ #include "Sample/SoftParticle/Gauss.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Util/Assert.h" #include "Sample/Shape/BoxNet.h" #include "Sample/Shape/TruncatedEllipsoidNet.h" #include <limits> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; GaussSphere::GaussSphere(const std::vector<double> P) : IFormfactor(P) diff --git a/Sample/StandardSample/SlicedCylindersBuilder.cpp b/Sample/StandardSample/SlicedCylindersBuilder.cpp index 866f60e06213e3faccf7774d068fb688518df5af..ba4818b2a96c4f52fb043c251e616105a9325344 100644 --- a/Sample/StandardSample/SlicedCylindersBuilder.cpp +++ b/Sample/StandardSample/SlicedCylindersBuilder.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "Sample/StandardSample/SlicedCylindersBuilder.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Const/Units.h" #include "Sample/Aggregate/ParticleLayout.h" #include "Sample/HardParticle/Cylinder.h" @@ -20,9 +21,8 @@ #include "Sample/Multilayer/Layer.h" #include "Sample/Multilayer/MultiLayer.h" #include "Sample/Particle/Particle.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { diff --git a/Sim/Computation/RoughMultiLayerContribution.cpp b/Sim/Computation/RoughMultiLayerContribution.cpp index 3c089527bcc53d0c0942b66120f2accf932e3544..ce487881e67d53ed97dba8ccd3d098031591d258 100644 --- a/Sim/Computation/RoughMultiLayerContribution.cpp +++ b/Sim/Computation/RoughMultiLayerContribution.cpp @@ -14,6 +14,7 @@ #include "Sim/Computation/RoughMultiLayerContribution.h" #include "3rdparty/Core/cerfcpp.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Util/Assert.h" #include "Resample/Element/DiffuseElement.h" #include "Resample/Flux/ScalarFlux.h" @@ -22,9 +23,8 @@ #include "Sample/Interface/LayerRoughness.h" #include "Sample/Multilayer/Layer.h" #include "Sample/Multilayer/MultiLayer.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; // As we say in our 2020 paper (Sect 5.6), diffuse scattering from rough interfaces // is modelled after Schlomka et al, Phys Rev B, 51, 2311 (1995). They give credit diff --git a/Sim/Export/MaterialKeyHandler.cpp b/Sim/Export/MaterialKeyHandler.cpp index 7e2c9814cc5446bc950e51b4f1ec2c31cea2408d..09f556349d0ac40342a99822d24bb58f0d43940b 100644 --- a/Sim/Export/MaterialKeyHandler.cpp +++ b/Sim/Export/MaterialKeyHandler.cpp @@ -26,7 +26,14 @@ void MaterialKeyHandler::insertMaterial(const Material* mat) m_Mat2Unique.emplace(mat, mat); const std::string key = "material_" + mat->materialName(); - ASSERT(!m_Key2Mat.contains(key)); // material must not be exported more than once + + // material must not be exported more than once +#ifdef BA_CPP20 + ASSERT(!m_Key2Mat.contains(key)); +#else + ASSERT(m_Key2Mat.find(key) == m_Key2Mat.end()); +#endif // BA_CPP20 + m_Key2Mat.emplace(key, mat); } diff --git a/Sim/Scan/AlphaScan.cpp b/Sim/Scan/AlphaScan.cpp index 31a12fff61c331eb5309691f23a9ec972a26e55e..310d7367d4b26557ff8c34711094a34487e33da0 100644 --- a/Sim/Scan/AlphaScan.cpp +++ b/Sim/Scan/AlphaScan.cpp @@ -15,6 +15,7 @@ #include "Sim/Scan/AlphaScan.h" #include "Base/Axis/MakeScale.h" #include "Base/Axis/Scale.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Math/Numeric.h" #include "Base/Vector/GisasDirection.h" #include "Device/Beam/Beam.h" @@ -24,9 +25,8 @@ #include "Param/Distrib/ParameterSample.h" #include "Resample/Element/SpecularElement.h" #include <algorithm> // is_sorted -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; namespace { @@ -50,7 +50,7 @@ AlphaScan::AlphaScan(const Scale& alpha_axis) "sorted in ascending order."); if (axis_values.front() < 0) throw std::runtime_error("AlphaScan: negative angles."); - if (axis_values.back() > std::numbers::pi / 2) + if (axis_values.back() > pi / 2) throw std::runtime_error("AlphaScan: angles beyond normal."); m_beams.clear(); diff --git a/Sim/Scan/LambdaScan.cpp b/Sim/Scan/LambdaScan.cpp index 1b5dc293d48adab23b84c6d7b5d89420db97d086..b14d0f136c447a8c7ffe60eab32a1521961e8594 100644 --- a/Sim/Scan/LambdaScan.cpp +++ b/Sim/Scan/LambdaScan.cpp @@ -15,14 +15,14 @@ #include "Sim/Scan/LambdaScan.h" #include "Base/Axis/MakeScale.h" #include "Base/Axis/Scale.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Vector/GisasDirection.h" #include "Device/Beam/Beam.h" #include "Device/Beam/IFootprint.h" #include "Resample/Element/SpecularElement.h" #include <algorithm> // is_sorted -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; LambdaScan::LambdaScan(Scale* lambdaScale) : PhysicalScan(lambdaScale) diff --git a/Sim/Scan/QzScan.cpp b/Sim/Scan/QzScan.cpp index b18d57ac1441a9c386137ff3a14c0fcec7e8bb9e..8c0a17ae74ebd0007674541d065748fff1b60ad4 100644 --- a/Sim/Scan/QzScan.cpp +++ b/Sim/Scan/QzScan.cpp @@ -15,6 +15,7 @@ #include "Sim/Scan/QzScan.h" #include "Base/Axis/MakeScale.h" #include "Base/Axis/Scale.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Util/Assert.h" #include "Device/Beam/Beam.h" #include "Device/Pol/PolFilter.h" @@ -22,9 +23,8 @@ #include "Param/Distrib/ParameterSample.h" #include "Resample/Element/SpecularElement.h" #include <algorithm> // is_sorted -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; QzScan::QzScan(Scale* qs_nm) : BeamScan(qs_nm) diff --git a/Sim/Simulation/DepthprobeSimulation.cpp b/Sim/Simulation/DepthprobeSimulation.cpp index 5772a2df6f1d026d24c4ece31fd05db0e31ee89c..75eb6af8d317cb1871cf03b039240d95b5fb991f 100644 --- a/Sim/Simulation/DepthprobeSimulation.cpp +++ b/Sim/Simulation/DepthprobeSimulation.cpp @@ -15,6 +15,7 @@ #include "Sim/Simulation/DepthprobeSimulation.h" #include "Base/Axis/Frame.h" #include "Base/Axis/Scale.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Progress/ProgressHandler.h" #include "Base/Util/Assert.h" #include "Base/Vector/GisasDirection.h" @@ -26,10 +27,9 @@ #include "Resample/Flux/ScalarFlux.h" #include "Resample/Processed/ReSample.h" #include "Sim/Scan/AlphaScan.h" -#include <numbers> #include <valarray> -using std::numbers::pi; +using PhysConsts::pi; const int ZDirection_None = 0; const int ZDirection_Reflected = 1; diff --git a/Tests/SimFactory/MakeSimulations.cpp b/Tests/SimFactory/MakeSimulations.cpp index 5d3dbd1f268db3f6029424101948403f502ee7be..f422193728db938cfc2a8961b800561feca6db47 100644 --- a/Tests/SimFactory/MakeSimulations.cpp +++ b/Tests/SimFactory/MakeSimulations.cpp @@ -15,6 +15,7 @@ #include "Tests/SimFactory/MakeSimulations.h" #include "Base/Axis/MakeScale.h" #include "Base/Axis/Scale.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Const/Units.h" #include "Device/Beam/Beam.h" #include "Device/Beam/FootprintGauss.h" @@ -34,9 +35,8 @@ #include "Sim/Simulation/includeSimulations.h" #include <algorithm> #include <map> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; using Units::angstrom; using Units::deg; diff --git a/Tests/Unit/Base/PointwiseAxisTest.cpp b/Tests/Unit/Base/PointwiseAxisTest.cpp index d30f442e2a050bdfeac0ba332c222ddaa93a759f..025b63a488f1d2aed1fdeac417f5a015f3740949 100644 --- a/Tests/Unit/Base/PointwiseAxisTest.cpp +++ b/Tests/Unit/Base/PointwiseAxisTest.cpp @@ -89,7 +89,7 @@ TEST(PointwiseAxis, ClippedAxis) EXPECT_TRUE(clip2 == axis); Scale clip3 = axis.clipped(1.5, 2.5); - EXPECT_TRUE(clip3 != axis); + EXPECT_TRUE(!(clip3 == axis)); EXPECT_EQ(clip3.size(), 2u); EXPECT_EQ(clip3.binCenter(0), 2.0); EXPECT_EQ(clip3.binCenter(1), 2.5); diff --git a/Tests/Unit/Numeric/BisectFF.cpp b/Tests/Unit/Numeric/BisectFF.cpp index 030fe693d05439dbe90e5dfbfbd6c3e5c9dd2e10..b86994e394422ad51d665c7dce1a90170fe63a5d 100644 --- a/Tests/Unit/Numeric/BisectFF.cpp +++ b/Tests/Unit/Numeric/BisectFF.cpp @@ -1,5 +1,6 @@ #ifdef ALGORITHM_DIAGNOSTIC +#include "Base/Const/PhysicalConstants.h" #include "Sample/HardParticle/HardParticles.h" #include "Tests/GTestWrapper/google_test.h" #include <cassert> @@ -7,10 +8,9 @@ #include <ff/Face.h> // ?? #include <iomanip> #include <iostream> -#include <numbers> #include <vector> -using std::numbers::pi; +using PhysConsts::pi; const auto qlist = testing::Combine( testing::Values(C3({1, 0, 0}), C3({0, 1, 0}), C3({0, 0, 1}), C3({1, 1, 0}), C3({1, 0, 1}), diff --git a/Tests/Unit/Numeric/FormfactorOtherTest.cpp b/Tests/Unit/Numeric/FormfactorOtherTest.cpp index a2fe249a5e8d4db0e5e90b15220f39b6b60b4203..a59a9b56a56f7ea0c3ff28d462518eadcc116fef 100644 --- a/Tests/Unit/Numeric/FormfactorOtherTest.cpp +++ b/Tests/Unit/Numeric/FormfactorOtherTest.cpp @@ -1,10 +1,10 @@ #include "Sample/HardParticle/HardParticles.h" +#include "Base/Const/PhysicalConstants.h" #include "Sample/Scattering/Rotations.h" #include "Tests/Unit/Numeric/MultiQTest.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; class FormfactorOtherTest : public testing::Test {}; diff --git a/Tests/Unit/Numeric/FormfactorSymmetryTest.cpp b/Tests/Unit/Numeric/FormfactorSymmetryTest.cpp index 2a1197589b859d425832c1732ab08b11bce97692..69b0958ea7df7d659be0ce6c776c6f5ac4cf1bd6 100644 --- a/Tests/Unit/Numeric/FormfactorSymmetryTest.cpp +++ b/Tests/Unit/Numeric/FormfactorSymmetryTest.cpp @@ -1,6 +1,6 @@ -#include <numbers> +#include "Base/Const/PhysicalConstants.h" -using std::numbers::pi; +using PhysConsts::pi; #include "Sample/HardParticle/HardParticles.h" #include "Tests/GTestWrapper/google_test.h" diff --git a/Tests/Unit/Numeric/SpecialFunctionsTest.cpp b/Tests/Unit/Numeric/SpecialFunctionsTest.cpp index 913b39f23761e5082ec1ef4babfbacb0ac26e919..215192439711363c569c5cf136d6322499d9479a 100644 --- a/Tests/Unit/Numeric/SpecialFunctionsTest.cpp +++ b/Tests/Unit/Numeric/SpecialFunctionsTest.cpp @@ -1,6 +1,6 @@ -#include <numbers> +#include "Base/Const/PhysicalConstants.h" -using std::numbers::pi; +using PhysConsts::pi; #include "Base/Math/Functions.h" #include "Tests/GTestWrapper/google_test.h" diff --git a/Tests/Unit/Resample/MaterialTest.cpp b/Tests/Unit/Resample/MaterialTest.cpp index a1938a0546a966bea67147657fe49159a04f9c0b..ac851d4858d5b77a16b1db1c46c3045cf20c5164 100644 --- a/Tests/Unit/Resample/MaterialTest.cpp +++ b/Tests/Unit/Resample/MaterialTest.cpp @@ -1,5 +1,6 @@ #include "Base/Const/Units.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Vector/RotMatrix.h" #include "Base/Vector/WavevectorInfo.h" #include "Sample/Material/MaterialFactoryFuncs.h" @@ -7,9 +8,8 @@ #include "Sample/Scattering/Rotations.h" #include "Tests/GTestWrapper/google_test.h" #include <iostream> -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; TEST(Material, MaterialConstruction) { diff --git a/Tests/Unit/Sample/FormfactorBasicTest.cpp b/Tests/Unit/Sample/FormfactorBasicTest.cpp index 1e304af409478b388be0ff90fbc9f2995e373403..c646d56e16ef2f2f6737bc0ed6608c6afa2cc4f6 100644 --- a/Tests/Unit/Sample/FormfactorBasicTest.cpp +++ b/Tests/Unit/Sample/FormfactorBasicTest.cpp @@ -1,12 +1,12 @@ #include "Base/Const/Units.h" +#include "Base/Const/PhysicalConstants.h" #include "Base/Type/Span.h" #include "Sample/HardParticle/HardParticles.h" #include "Sample/Scattering/Rotations.h" #include "Tests/GTestWrapper/google_test.h" -#include <numbers> -using std::numbers::pi; +using PhysConsts::pi; using namespace std::complex_literals; void test_eps_q(const IFormfactor* p, C3 qdir, double eps) diff --git a/Tests/Unit/Sample/LatticeTest.cpp b/Tests/Unit/Sample/LatticeTest.cpp index c4c314e3092ef02923ce2e221f89483ee7e784fd..92d244120ff12d2fabc407f3192226d039ee1463 100644 --- a/Tests/Unit/Sample/LatticeTest.cpp +++ b/Tests/Unit/Sample/LatticeTest.cpp @@ -1,6 +1,6 @@ -#include <numbers> +#include "Base/Const/PhysicalConstants.h" -using std::numbers::pi; +using PhysConsts::pi; #include "Base/Vector/RotMatrix.h" #include "Sample/Lattice/BakeLattice.h"