Skip to content

Commit

Permalink
Merge pull request #1045 from boostorg/ccmath_config
Browse files Browse the repository at this point in the history
Update/improve ccmath configuration.
  • Loading branch information
jzmaddock authored Nov 5, 2023
2 parents 8435aef + 21230d6 commit 11e2348
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 88 deletions.
13 changes: 3 additions & 10 deletions include/boost/math/ccmath/abs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@
#ifndef BOOST_MATH_CCMATH_ABS
#define BOOST_MATH_CCMATH_ABS

#include <cmath>
#include <type_traits>
#include <limits>
#include <boost/math/tools/is_constant_evaluated.hpp>
#include <boost/math/tools/assert.hpp>
#include <boost/math/ccmath/detail/config.hpp>
#include <boost/math/ccmath/isnan.hpp>
#include <boost/math/ccmath/isinf.hpp>

#include <boost/math/tools/is_standalone.hpp>
#ifndef BOOST_MATH_STANDALONE
#include <boost/config.hpp>
#ifdef BOOST_NO_CXX17_IF_CONSTEXPR
#error "The header <boost/math/norms.hpp> can only be used in C++17 and later."
#endif
#ifdef BOOST_MATH_NO_CCMATH
#error "The header <boost/math/abs.hpp> can only be used in C++17 and later."
#endif

namespace boost::math::ccmath {
Expand Down
34 changes: 34 additions & 0 deletions include/boost/math/ccmath/detail/config.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// (C) Copyright John Maddock 2023.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Core configuration for ccmath functions, basically will they work or not?

#ifndef BOOST_MATH_CCMATH_DETAIL_CONFIG
#define BOOST_MATH_CCMATH_DETAIL_CONFIG

#include <cmath>
#include <type_traits>
#include <limits>
#include <boost/math/tools/is_constant_evaluated.hpp>
#include <boost/math/tools/is_standalone.hpp>

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

#ifndef _MSC_VER
//
// Don't check here for msvc as they didn't get std lib configuration macros at the same time as C++17 <type_traits>
//
#if (__cpp_lib_bool_constant < 201505L) && !defined(BOOST_MATH_NO_CCMATH)
# define BOOST_MATH_NO_CCMATH
#endif
#endif


#endif
12 changes: 3 additions & 9 deletions include/boost/math/ccmath/div.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@
#ifndef BOOST_MATH_CCMATH_DIV_HPP
#define BOOST_MATH_CCMATH_DIV_HPP

#include <cmath>
#include <cstdlib>
#include <cinttypes>
#include <cstdint>
#include <type_traits>
#include <boost/math/ccmath/detail/config.hpp>

#include <boost/math/tools/is_standalone.hpp>
#ifndef BOOST_MATH_STANDALONE
#include <boost/config.hpp>
#ifdef BOOST_NO_CXX17_IF_CONSTEXPR
#error "The header <boost/math/norms.hpp> can only be used in C++17 and later."
#endif
#ifdef BOOST_MATH_NO_CCMATH
#error "The header <boost/math/div.hpp> can only be used in C++17 and later."
#endif

namespace boost::math::ccmath {
Expand Down
13 changes: 3 additions & 10 deletions include/boost/math/ccmath/fma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,12 @@
#ifndef BOOST_MATH_CCMATH_FMA_HPP
#define BOOST_MATH_CCMATH_FMA_HPP

#include <cmath>
#include <limits>
#include <type_traits>
#include <boost/math/tools/is_constant_evaluated.hpp>
#include <boost/math/ccmath/detail/config.hpp>
#include <boost/math/ccmath/isinf.hpp>
#include <boost/math/ccmath/isnan.hpp>

#include <boost/math/tools/is_standalone.hpp>
#ifndef BOOST_MATH_STANDALONE
#include <boost/config.hpp>
#ifdef BOOST_NO_CXX17_IF_CONSTEXPR
#error "The header <boost/math/norms.hpp> can only be used in C++17 and later."
#endif
#ifdef BOOST_MATH_NO_CCMATH
#error "The header <boost/math/fma.hpp> can only be used in C++17 and later."
#endif

namespace boost::math::ccmath {
Expand Down
13 changes: 3 additions & 10 deletions include/boost/math/ccmath/isinf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@
#ifndef BOOST_MATH_CCMATH_ISINF
#define BOOST_MATH_CCMATH_ISINF

#include <cmath>
#include <limits>
#include <type_traits>
#include <boost/math/tools/is_constant_evaluated.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/ccmath/detail/config.hpp>

#include <boost/math/tools/is_standalone.hpp>
#ifndef BOOST_MATH_STANDALONE
#include <boost/config.hpp>
#ifdef BOOST_NO_CXX17_IF_CONSTEXPR
#error "The header <boost/math/norms.hpp> can only be used in C++17 and later."
#endif
#ifdef BOOST_MATH_NO_CCMATH
#error "The header <boost/math/isinf.hpp> can only be used in C++17 and later."
#endif

namespace boost::math::ccmath {
Expand Down
12 changes: 3 additions & 9 deletions include/boost/math/ccmath/isnan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@
#ifndef BOOST_MATH_CCMATH_ISNAN
#define BOOST_MATH_CCMATH_ISNAN

#include <cmath>
#include <type_traits>
#include <boost/math/tools/is_constant_evaluated.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/ccmath/detail/config.hpp>

#include <boost/math/tools/is_standalone.hpp>
#ifndef BOOST_MATH_STANDALONE
#include <boost/config.hpp>
#ifdef BOOST_NO_CXX17_IF_CONSTEXPR
#error "The header <boost/math/norms.hpp> can only be used in C++17 and later."
#endif
#ifdef BOOST_MATH_NO_CCMATH
#error "The header <boost/math/isnan.hpp> can only be used in C++17 and later."
#endif

namespace boost::math::ccmath {
Expand Down
13 changes: 3 additions & 10 deletions include/boost/math/ccmath/isnormal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@
#ifndef BOOST_MATH_ISNORMAL_HPP
#define BOOST_MATH_ISNORMAL_HPP

#include <cmath>
#include <limits>
#include <type_traits>
#include <boost/math/tools/is_constant_evaluated.hpp>
#include <boost/math/ccmath/detail/config.hpp>
#include <boost/math/ccmath/abs.hpp>
#include <boost/math/ccmath/isinf.hpp>
#include <boost/math/ccmath/isnan.hpp>

#include <boost/math/tools/is_standalone.hpp>
#ifndef BOOST_MATH_STANDALONE
#include <boost/config.hpp>
#ifdef BOOST_NO_CXX17_IF_CONSTEXPR
#error "The header <boost/math/norms.hpp> can only be used in C++17 and later."
#endif
#ifdef BOOST_MATH_NO_CCMATH
#error "The header <boost/math/abs.hpp> can only be used in C++17 and later."
#endif

namespace boost::math::ccmath {
Expand Down
5 changes: 1 addition & 4 deletions include/boost/math/ccmath/ldexp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
#ifndef BOOST_MATH_CCMATH_LDEXP_HPP
#define BOOST_MATH_CCMATH_LDEXP_HPP

#include <cmath>
#include <limits>
#include <type_traits>
#include <stdexcept>
#include <boost/math/tools/is_constant_evaluated.hpp>
#include <boost/math/ccmath/detail/config.hpp>
#include <boost/math/ccmath/abs.hpp>
#include <boost/math/ccmath/isinf.hpp>
#include <boost/math/ccmath/isnan.hpp>
Expand Down
12 changes: 3 additions & 9 deletions include/boost/math/ccmath/round.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@
#ifndef BOOST_MATH_CCMATH_ROUND_HPP
#define BOOST_MATH_CCMATH_ROUND_HPP

#include <cmath>
#include <type_traits>
#include <stdexcept>
#include <boost/math/tools/is_constant_evaluated.hpp>
#include <boost/math/ccmath/detail/config.hpp>
#include <boost/math/ccmath/abs.hpp>
#include <boost/math/ccmath/isinf.hpp>
#include <boost/math/ccmath/isnan.hpp>
#include <boost/math/ccmath/modf.hpp>

#include <boost/math/tools/is_standalone.hpp>
#ifndef BOOST_MATH_STANDALONE
#include <boost/config.hpp>
#ifdef BOOST_NO_CXX17_IF_CONSTEXPR
#error "The header <boost/math/norms.hpp> can only be used in C++17 and later."
#endif
#ifdef BOOST_MATH_NO_CCMATH
#error "The header <boost/math/round.hpp> can only be used in C++17 and later."
#endif

namespace boost::math::ccmath {
Expand Down
13 changes: 3 additions & 10 deletions include/boost/math/ccmath/signbit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
#ifndef BOOST_MATH_CCMATH_SIGNBIT_HPP
#define BOOST_MATH_CCMATH_SIGNBIT_HPP

#include <cmath>
#include <cstdint>
#include <limits>
#include <type_traits>
#include <boost/math/tools/is_constant_evaluated.hpp>
#include <boost/math/tools/assert.hpp>
#include <boost/math/ccmath/detail/config.hpp>
#include <boost/math/special_functions/detail/fp_traits.hpp>
#include <boost/math/ccmath/isnan.hpp>
#include <boost/math/ccmath/abs.hpp>

#include <boost/math/tools/is_standalone.hpp>
#ifndef BOOST_MATH_STANDALONE
#include <boost/config.hpp>
#ifdef BOOST_NO_CXX17_IF_CONSTEXPR
#error "The header <boost/math/norms.hpp> can only be used in C++17 and later."
#endif
#ifdef BOOST_MATH_NO_CCMATH
#error "The header <boost/math/signbit.hpp> can only be used in C++17 and later."
#endif

#ifdef __has_include
Expand Down
5 changes: 2 additions & 3 deletions include/boost/math/special_functions/round.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@
#endif

#include <boost/math/tools/config.hpp>
#include <boost/math/ccmath/detail/config.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/special_functions/math_fwd.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <type_traits>
#include <limits>
#include <cmath>

#ifndef BOOST_NO_CXX17_IF_CONSTEXPR
#if !defined(BOOST_MATH_NO_CCMATH) && !defined(BOOST_MATH_NO_CONSTEXPR_DETECTION)
#include <boost/math/ccmath/ldexp.hpp>
# if !defined(BOOST_MATH_NO_CONSTEXPR_DETECTION)
# define BOOST_MATH_HAS_CONSTEXPR_LDEXP
# endif
#endif

namespace boost{ namespace math{
Expand Down
7 changes: 3 additions & 4 deletions include/boost/math/special_functions/trunc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
#include <type_traits>
#include <boost/math/special_functions/math_fwd.hpp>
#include <boost/math/tools/config.hpp>
#include <boost/math/ccmath/detail/config.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/tools/is_constant_evaluated.hpp>

#ifndef BOOST_NO_CXX17_IF_CONSTEXPR
# if !defined(BOOST_MATH_NO_CONSTEXPR_DETECTION)
# include <boost/math/ccmath/ldexp.hpp>
#if !defined(BOOST_MATH_NO_CCMATH) && !defined(BOOST_MATH_NO_CONSTEXPR_DETECTION)
#include <boost/math/ccmath/ldexp.hpp>
# define BOOST_MATH_HAS_CONSTEXPR_LDEXP
# endif
#endif

namespace boost{ namespace math{ namespace detail{
Expand Down

0 comments on commit 11e2348

Please sign in to comment.