diff --git a/avogadro/core/avogadrocore.h b/avogadro/core/avogadrocore.h index 53ec43ce32..9a0306146f 100644 --- a/avogadro/core/avogadrocore.h +++ b/avogadro/core/avogadrocore.h @@ -1,4 +1,4 @@ -/****************************************************************************** + /****************************************************************************** This source file is part of the Avogadro project. This source code is released under the 3-Clause BSD License, (see "LICENSE"). ******************************************************************************/ @@ -9,83 +9,72 @@ #include #include -/** Prevent compiler error when using std::numeric_limits::max() */ -#if defined(_MSC_VER) && defined(max) -#undef max -#endif - /** * This macro marks a parameter as unused. Its purpose is to disable the * compiler from emitting unused parameter warnings. */ #define AVO_UNUSED(variable) (void)variable -/** - * This macro marks a class as not copyable. It should be used in the private - * section of a class's declaration. - */ -#define AVO_DISABLE_COPY(Class) \ - Class(const Class&); \ - Class& operator=(const Class&); - namespace Avogadro { /** Typedef for a real number. */ -typedef double Real; +using Real = double; /** Typedef for indices and sizes. */ -typedef size_t Index; -const Index MaxIndex = std::numeric_limits::max(); +using Index = std::size_t; +constexpr Index MaxIndex = std::numeric_limits::max(); /** Used to represent an invalid atomic number. */ -const unsigned char InvalidElement = 255; +constexpr unsigned char InvalidElement = 255; /** * Minimum value for atomic numbers that represent custom, non-elemental - * particles. */ -const unsigned char CustomElementMin = 128; + * particles. + */ +constexpr unsigned char CustomElementMin = 128; /** * Maximum value for atomic numbers that represent custom, non-elemental - * particles. */ -const unsigned char CustomElementMax = 254; + * particles. + */ +constexpr unsigned char CustomElementMax = 254; /** * Count of atomic number values that are used to represent custom, - * non-elemental particles. */ -const unsigned char CustomElementCount = - CustomElementMax - CustomElementMin + 1; + * non-elemental particles. + */ +constexpr unsigned char CustomElementCount = + CustomElementMax - CustomElementMin + 1; /** * @return True if @a atomicNumber denotes a custom element type. */ namespace Core { -inline bool isCustomElement(unsigned char atomicNumber) -{ - return atomicNumber >= CustomElementMin && atomicNumber <= CustomElementMax; +constexpr bool isCustomElement(unsigned char atomicNumber) { + return atomicNumber >= CustomElementMin && atomicNumber <= CustomElementMax; } } /** Unit conversion factors. @{ */ -const double PI_D = 3.141592653589793238462643; -const float PI_F = static_cast(PI_D); -const Real PI = static_cast(PI_D); +constexpr double PI_D = 3.141592653589793238462643; +constexpr float PI_F = static_cast(PI_D); +constexpr Real PI = static_cast(PI_D); -const double DEG_TO_RAD_D = PI_D / 180.0; -const float DEG_TO_RAD_F = static_cast(DEG_TO_RAD_D); -const Real DEG_TO_RAD = static_cast(DEG_TO_RAD_D); +constexpr double DEG_TO_RAD_D = PI_D / 180.0; +constexpr float DEG_TO_RAD_F = static_cast(DEG_TO_RAD_D); +constexpr Real DEG_TO_RAD = static_cast(DEG_TO_RAD_D); -const double RAD_TO_DEG_D = 180.0 / PI_D; -const float RAD_TO_DEG_F = static_cast(RAD_TO_DEG_D); -const Real RAD_TO_DEG = static_cast(RAD_TO_DEG_D); +constexpr double RAD_TO_DEG_D = 180.0 / PI_D; +constexpr float RAD_TO_DEG_F = static_cast(RAD_TO_DEG_D); +constexpr Real RAD_TO_DEG = static_cast(RAD_TO_DEG_D); -const double BOHR_TO_ANGSTROM_D = 0.52917721092; -const float BOHR_TO_ANGSTROM_F = static_cast(BOHR_TO_ANGSTROM_D); -const Real BOHR_TO_ANGSTROM = static_cast(BOHR_TO_ANGSTROM_D); +constexpr double BOHR_TO_ANGSTROM_D = 0.52917721092; +constexpr float BOHR_TO_ANGSTROM_F = static_cast(BOHR_TO_ANGSTROM_D); +constexpr Real BOHR_TO_ANGSTROM = static_cast(BOHR_TO_ANGSTROM_D); -const double ANGSTROM_TO_BOHR_D = 1.0 / BOHR_TO_ANGSTROM_D; -const float ANGSTROM_TO_BOHR_F = static_cast(ANGSTROM_TO_BOHR_D); -const Real ANGSTROM_TO_BOHR = static_cast(ANGSTROM_TO_BOHR_D); +constexpr double ANGSTROM_TO_BOHR_D = 1.0 / BOHR_TO_ANGSTROM_D; +constexpr float ANGSTROM_TO_BOHR_F = static_cast(ANGSTROM_TO_BOHR_D); +constexpr Real ANGSTROM_TO_BOHR = static_cast(ANGSTROM_TO_BOHR_D); /** @} */ } // end Avogadro namespace