Skip to content

Commit

Permalink
Merge pull request #1100 from boostorg/macro
Browse files Browse the repository at this point in the history
Replace redefinition of Boost.Config macros in Standalone mode
  • Loading branch information
mborland authored Feb 22, 2024
2 parents c1b95ac + c9be742 commit 2af21de
Show file tree
Hide file tree
Showing 189 changed files with 1,429 additions and 1,382 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ The full documentation is available on [boost.org](http://www.boost.org/doc/libs

Defining BOOST_MATH_STANDALONE allows Boost.Math to be used without any Boost dependencies.
Some functionality is reduced in this mode. A static_assert message will alert you
if a particular feature has been disabled by standalone mode.
if a particular feature has been disabled by standalone mode. Standalone mode is not designed to
be used with the rest of boost, and may result in compiler errors.

## Supported Compilers ##

Expand Down
2 changes: 1 addition & 1 deletion example/error_handling_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main()
{
cout << "Example error handling using Student's t function. " << endl;
cout << "BOOST_MATH_DOMAIN_ERROR_POLICY is set to: "
<< BOOST_STRINGIZE(BOOST_MATH_DOMAIN_ERROR_POLICY) << endl;
<< BOOST_MATH_STRINGIZE(BOOST_MATH_DOMAIN_ERROR_POLICY) << endl;

double degrees_of_freedom = -1; // A bad argument!
double t = 10;
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/ccmath/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef BOOST_MATH_STANDALONE

#include <boost/config.hpp>
#ifdef BOOST_NO_CXX17_IF_CONSTEXPR
#ifdef BOOST_MATH_NO_CXX17_IF_CONSTEXPR
# define BOOST_MATH_NO_CCMATH
#endif

Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/ccmath/fpclassify.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace boost::math::ccmath {

template <typename T, std::enable_if_t<!std::is_integral_v<T>, bool> = true>
inline constexpr int fpclassify BOOST_PREVENT_MACRO_SUBSTITUTION(T x)
inline constexpr int fpclassify BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T x)
{
if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))
{
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/ccmath/isinf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace boost::math::ccmath {

template <typename T>
constexpr bool isinf BOOST_PREVENT_MACRO_SUBSTITUTION(T x) noexcept
constexpr bool isinf BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T x) noexcept
{
if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))
{
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/ccmath/isnan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace boost::math::ccmath {

template <typename T>
inline constexpr bool isnan BOOST_PREVENT_MACRO_SUBSTITUTION(T x)
inline constexpr bool isnan BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T x)
{
if(BOOST_MATH_IS_CONSTANT_EVALUATED(x))
{
Expand Down
26 changes: 13 additions & 13 deletions include/boost/math/constants/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ namespace boost{ namespace math
>;
};

#ifdef BOOST_HAS_THREADS
#ifdef BOOST_MATH_HAS_THREADS
#define BOOST_MATH_CONSTANT_THREAD_HELPER(name, prefix) \
boost::once_flag f = BOOST_ONCE_INIT;\
boost::call_once(f, &BOOST_JOIN(BOOST_JOIN(string_, get_), name)<T>);
boost::call_once(f, &BOOST_MATH_JOIN(BOOST_MATH_JOIN(string_, get_), name)<T>);
#else
#define BOOST_MATH_CONSTANT_THREAD_HELPER(name, prefix)
#endif
Expand Down Expand Up @@ -162,20 +162,20 @@ namespace boost{ namespace math
#ifdef BOOST_MATH_USE_FLOAT128
# define BOOST_MATH_FLOAT128_CONSTANT_OVERLOAD(x) \
static inline constexpr T get(const std::integral_constant<int, construct_from_float128>&) noexcept\
{ return BOOST_JOIN(x, Q); }
{ return BOOST_MATH_JOIN(x, Q); }
#else
# define BOOST_MATH_FLOAT128_CONSTANT_OVERLOAD(x)
#endif

#ifdef BOOST_NO_CXX11_THREAD_LOCAL
# define BOOST_MATH_PRECOMPUTE_IF_NOT_LOCAL(constant_, name) constant_initializer<T, & BOOST_JOIN(constant_, name)<T>::get_from_variable_precision>::force_instantiate();
#ifdef BOOST_MATH_NO_CXX11_THREAD_LOCAL
# define BOOST_MATH_PRECOMPUTE_IF_NOT_LOCAL(constant_, name) constant_initializer<T, & BOOST_MATH_JOIN(constant_, name)<T>::get_from_variable_precision>::force_instantiate();
#else
# define BOOST_MATH_PRECOMPUTE_IF_NOT_LOCAL(constant_, name)
#endif

#define BOOST_DEFINE_MATH_CONSTANT(name, x, y)\
namespace detail{\
template <typename T> struct BOOST_JOIN(constant_, name){\
template <typename T> struct BOOST_MATH_JOIN(constant_, name){\
private:\
/* The default implementations come next: */ \
static inline const T& get_from_string()\
Expand Down Expand Up @@ -206,19 +206,19 @@ namespace boost{ namespace math
public:\
static inline const T& get(const std::integral_constant<int, construct_from_string>&)\
{\
constant_initializer<T, & BOOST_JOIN(constant_, name)<T>::get_from_string >::force_instantiate();\
constant_initializer<T, & BOOST_MATH_JOIN(constant_, name)<T>::get_from_string >::force_instantiate();\
return get_from_string();\
}\
static inline constexpr T get(const std::integral_constant<int, construct_from_float>) noexcept\
{ return BOOST_JOIN(x, F); }\
{ return BOOST_MATH_JOIN(x, F); }\
static inline constexpr T get(const std::integral_constant<int, construct_from_double>&) noexcept\
{ return x; }\
static inline constexpr T get(const std::integral_constant<int, construct_from_long_double>&) noexcept\
{ return BOOST_JOIN(x, L); }\
{ return BOOST_MATH_JOIN(x, L); }\
BOOST_MATH_FLOAT128_CONSTANT_OVERLOAD(x) \
template <int N> static inline const T& get(const std::integral_constant<int, N>&)\
{\
constant_initializer2<T, N, & BOOST_JOIN(constant_, name)<T>::template get_from_compute<N> >::force_instantiate();\
constant_initializer2<T, N, & BOOST_MATH_JOIN(constant_, name)<T>::template get_from_compute<N> >::force_instantiate();\
return get_from_compute<N>(); \
}\
/* This one is for true arbitrary precision, which may well vary at runtime: */ \
Expand All @@ -232,15 +232,15 @@ namespace boost{ namespace math
\
/* The actual forwarding function: */ \
template <typename T, typename Policy> inline constexpr typename detail::constant_return<T, Policy>::type name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T) BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(Policy)) BOOST_MATH_NOEXCEPT(T)\
{ return detail:: BOOST_JOIN(constant_, name)<T>::get(typename construction_traits<T, Policy>::type()); }\
{ return detail:: BOOST_MATH_JOIN(constant_, name)<T>::get(typename construction_traits<T, Policy>::type()); }\
template <typename T> inline constexpr typename detail::constant_return<T>::type name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) BOOST_MATH_NOEXCEPT(T)\
{ return name<T, boost::math::policies::policy<> >(); }\
\
\
/* Now the namespace specific versions: */ \
} namespace float_constants{ static constexpr float name = BOOST_JOIN(x, F); }\
} namespace float_constants{ static constexpr float name = BOOST_MATH_JOIN(x, F); }\
namespace double_constants{ static constexpr double name = x; } \
namespace long_double_constants{ static constexpr long double name = BOOST_JOIN(x, L); }\
namespace long_double_constants{ static constexpr long double name = BOOST_MATH_JOIN(x, L); }\
namespace constants{

BOOST_DEFINE_MATH_CONSTANT(half, 5.000000000000000000000000000000000000e-01, "5.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e-01")
Expand Down
Loading

0 comments on commit 2af21de

Please sign in to comment.