// Distributed under the Boost Software License Version 1.0 https://www.boost.org/LICENSE_1_0.txt // Copyright Gero Peterhoff #ifndef BOOST_MATH_CONSTANTS_MORE_HPP #define BOOST_MATH_CONSTANTS_MORE_HPP #include #include #include #include namespace boost { namespace math { namespace constants { #if defined(__cpp_concepts) #define BOOST_MAKE_MATH_CONSTANT(NAME, VALUE_F, VALUE_S) \ /* make non-constexpr constant in static_constants */ \ namespace static_constants { template requires (!std::is_floating_point_v) static const Type NAME##_v = boost::lexical_cast(VALUE_S); } \ /* make inline constexpr constant */ \ template requires (std::is_floating_point_v) inline constexpr Type NAME##_v = Type(BOOST_JOIN(VALUE_F, BOOST_FLOATMAX_SUFFIX)); \ /* getter for non-constexpr constant */ \ template requires (!std::is_floating_point_v) \ BOOST_FORCEINLINE Type NAME() noexcept { return static_constants::NAME##_v; } \ /* getter for constexpr constant */ \ template requires (std::is_floating_point_v) \ BOOST_FORCEINLINE constexpr Type NAME() noexcept { return NAME##_v; } #else // __cpp_concepts // helper: make inline constexpr constant if available #if defined(BOOST_NO_CXX17_INLINE_VARIABLES) #define BOOST_MAKE_MATH_CONSTANT_INLINE(NAME, VALUE_F) #else #define BOOST_MAKE_MATH_CONSTANT_INLINE(NAME, VALUE_F) \ template ::value, bool>::type = true> \ inline constexpr Type NAME##_v = Type(BOOST_JOIN(VALUE_F, BOOST_FLOATMAX_SUFFIX)); #endif #define BOOST_MAKE_MATH_CONSTANT(NAME, VALUE_F, VALUE_S) \ /* make non-constexpr constant in static_constants */ \ namespace static_constants { template ::value, bool>::type = true> static const Type NAME##_v = boost::lexical_cast(VALUE_S); } \ /* make inline constexpr constant */ \ BOOST_MAKE_MATH_CONSTANT_INLINE(NAME, VALUE_F) \ /* getter for non-constexpr constant */ \ template ::value, bool>::type = true> \ BOOST_FORCEINLINE Type NAME() noexcept { return static_constants::NAME##_v; } \ /* getter for constexpr constant */ \ template ::value, bool>::type = true> \ BOOST_FORCEINLINE BOOST_CONSTEXPR Type NAME() noexcept { return Type(BOOST_JOIN(VALUE_F, BOOST_FLOATMAX_SUFFIX)); } #endif // __cpp_concepts BOOST_MAKE_MATH_CONSTANT(psi, -0.61803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939113748475408808, "-0.61803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939113748475408808") BOOST_MAKE_MATH_CONSTANT(root_five, 2.23606797749978969640917366873127631939404588074105727133751596842430563183423686268724850378930568695068359375, "2.23606797749978969640917366873127631939404588074105727133751596842430563183423686268724850378930568695068359375") //BOOST_DEFINE_MATH_CONSTANT(psi, -0.61803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939113748475408808, "-0.61803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939113748475408808") //BOOST_DEFINE_MATH_CONSTANT(root_five, 2.23606797749978969640917366873127631939404588074105727133751596842430563183423686268724850378930568695068359375, "2.23606797749978969640917366873127631939404588074105727133751596842430563183423686268724850378930568695068359375") } // constants } // math } // boost #endif // BOOST_MATH_CONSTANTS_MORE_HPP