2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Remove boost.type_traits dependency

This commit is contained in:
Matt Borland
2021-03-20 14:15:09 +03:00
parent a343282477
commit 4b6ad919b3
22 changed files with 68 additions and 70 deletions

View File

@@ -27,7 +27,7 @@
// can find the definitions referred to herein.
//
#include <boost/type_traits/is_same.hpp>
#include <cmath>
#include <boost/math/tools/assert.hpp>
#ifdef BOOST_MSVC

View File

@@ -44,10 +44,6 @@
#include <boost/math/tools/roots.hpp> // for root finding.
#include <boost/math/distributions/detail/inv_discrete_quantile.hpp>
#include <boost/type_traits/is_floating_point.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_same.hpp>
#include <limits> // using std::numeric_limits;
#include <utility>

View File

@@ -52,10 +52,6 @@
#include <boost/math/tools/roots.hpp> // for root finding.
#include <boost/math/distributions/detail/inv_discrete_quantile.hpp>
#include <boost/type_traits/is_floating_point.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_same.hpp>
#include <limits> // using std::numeric_limits;
#include <utility>

View File

@@ -40,7 +40,7 @@ public:
barycentric_rational(std::vector<Real>&& x, std::vector<Real>&& y, size_t approximation_order = 3);
template <class InputIterator1, class InputIterator2>
barycentric_rational(InputIterator1 start_x, InputIterator1 end_x, InputIterator2 start_y, size_t approximation_order = 3, typename boost::disable_if_c<boost::is_integral<InputIterator2>::value>::type* = 0);
barycentric_rational(InputIterator1 start_x, InputIterator1 end_x, InputIterator2 start_y, size_t approximation_order = 3, typename std::enable_if<!std::is_integral<InputIterator2>::value>::type* = 0);
Real operator()(Real x) const;
@@ -77,7 +77,7 @@ barycentric_rational<Real>::barycentric_rational(std::vector<Real>&& x, std::vec
template <class Real>
template <class InputIterator1, class InputIterator2>
barycentric_rational<Real>::barycentric_rational(InputIterator1 start_x, InputIterator1 end_x, InputIterator2 start_y, size_t approximation_order, typename boost::disable_if_c<boost::is_integral<InputIterator2>::value>::type*)
barycentric_rational<Real>::barycentric_rational(InputIterator1 start_x, InputIterator1 end_x, InputIterator2 start_y, size_t approximation_order, typename std::enable_if<!std::is_integral<InputIterator2>::value>::type*)
: m_imp(std::make_shared<detail::barycentric_rational_imp<Real>>(start_x, end_x, start_y, approximation_order))
{
}

View File

@@ -7,7 +7,10 @@
#ifndef BOOST_MATH_QUADRATURE_DETAIL_TANH_SINH_CONSTANTS_HPP
#define BOOST_MATH_QUADRATURE_DETAIL_TANH_SINH_CONSTANTS_HPP
#include <boost/type_traits/is_constructible.hpp>
#include <cmath>
#include <cstddef>
#include <vector>
#include <type_traits>
#include <boost/lexical_cast.hpp>
namespace boost {

View File

@@ -13,8 +13,6 @@
#include <boost/config.hpp> // for BOOST_NO_STD_LOCALE
#include <boost/math_fwd.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/utility/enable_if.hpp>
#ifndef BOOST_NO_STD_LOCALE
# include <locale> // for the "<<" operator
#endif /* BOOST_NO_STD_LOCALE */

View File

@@ -20,7 +20,6 @@
#include <boost/math/special_functions/detail/bessel_jy_series.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/type_traits/is_floating_point.hpp>
#include <complex>
// Bessel functions of the first and second kind of fractional order

View File

@@ -21,13 +21,12 @@ With these techniques, the code could be simplified.
#endif
#include <cstring>
#include <cstdint>
#include <limits>
#include <type_traits>
#include <boost/math/tools/assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/predef/other/endian.h>
#include <boost/math/tools/assert.hpp>
#include <boost/type_traits/is_floating_point.hpp>
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std{ using ::memcpy; }
@@ -526,7 +525,7 @@ template<> struct size_to_precision<16, true>
template <class T>
struct select_native
{
typedef BOOST_DEDUCED_TYPENAME size_to_precision<sizeof(T), ::boost::is_floating_point<T>::value>::type precision;
typedef BOOST_DEDUCED_TYPENAME size_to_precision<sizeof(T), ::std::is_floating_point<T>::value>::type precision;
typedef fp_traits_non_native<T, precision> type;
};
template<>
@@ -564,7 +563,7 @@ struct select_native<long double>
template<class T> struct fp_traits
{
typedef BOOST_DEDUCED_TYPENAME size_to_precision<sizeof(T), ::boost::is_floating_point<T>::value>::type precision;
typedef BOOST_DEDUCED_TYPENAME size_to_precision<sizeof(T), ::std::is_floating_point<T>::value>::type precision;
#if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && !defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY)
typedef typename select_native<T>::type type;
#else

View File

@@ -10,8 +10,8 @@
#pragma once
#endif
#include <type_traits>
#include <boost/math/special_functions/round.hpp>
#include <boost/type_traits/is_convertible.hpp>
namespace boost { namespace math { namespace detail{

View File

@@ -33,11 +33,11 @@
#include <boost/math/special_functions/detail/lgamma_small.hpp>
#include <boost/math/special_functions/bernoulli.hpp>
#include <boost/math/special_functions/polygamma.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/math/tools/assert.hpp>
#include <cmath>
#include <algorithm>
#include <type_traits>
#ifdef BOOST_MSVC
# pragma warning(push)

View File

@@ -58,7 +58,6 @@ BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES_ITERATIONS // Show evaluation of
#include <boost/math/tools/series.hpp> // series functor.
//#include <boost/math/tools/polynomial.hpp> // polynomial.
#include <boost/math/tools/rational.hpp> // evaluate_polynomial.
#include <boost/type_traits/is_integral.hpp>
#include <boost/math/tools/precision.hpp> // boost::math::tools::max_value().
#include <boost/math/tools/big_constant.hpp>
#include <boost/math/tools/cxx03_warn.hpp>
@@ -1744,7 +1743,7 @@ T lambert_wm1_imp(const T z, const Policy& pol)
// Integral types should be promoted to double by user Lambert w functions.
// If integral type provided to user function lambert_w0 or lambert_wm1,
// then should already have been promoted to double.
static_assert(!boost::is_integral<T>::value,
static_assert(!std::is_integral<T>::value,
"Must be floating-point or fixed type (not integer type), for example: lambert_wm1(1.), not lambert_wm1(1)!");
BOOST_MATH_STD_USING // Aid argument dependent lookup (ADL) of abs.

View File

@@ -9,16 +9,16 @@
#ifdef _MSC_VER
#pragma once
#endif
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/math/special_functions/math_fwd.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/special_functions/sign.hpp>
#include <boost/math/special_functions/trunc.hpp>
#include <boost/math/tools/traits.hpp>
#include <type_traits>
#include <cfloat>
#include <float.h>
#if !defined(_CRAYC) && !defined(__CUDACC__) && (!defined(__GNUC__) || (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 3)))
#if (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(__SSE2__)
@@ -684,18 +684,18 @@ inline typename tools::promote_args<T, U>::type float_distance(const T& a, const
// We allow ONE of a and b to be an integer type, otherwise both must be the SAME type.
//
static_assert(
(boost::is_same<T, U>::value
|| (boost::is_integral<T>::value && !boost::is_integral<U>::value)
|| (!boost::is_integral<T>::value && boost::is_integral<U>::value)
(std::is_same<T, U>::value
|| (std::is_integral<T>::value && !std::is_integral<U>::value)
|| (!std::is_integral<T>::value && std::is_integral<U>::value)
|| (std::numeric_limits<T>::is_specialized && std::numeric_limits<U>::is_specialized
&& (std::numeric_limits<T>::digits == std::numeric_limits<U>::digits)
&& (std::numeric_limits<T>::radix == std::numeric_limits<U>::radix)
&& !std::numeric_limits<T>::is_integer && !std::numeric_limits<U>::is_integer)),
"Float distance between two different floating point types is undefined.");
BOOST_IF_CONSTEXPR (!boost::is_same<T, U>::value)
BOOST_IF_CONSTEXPR (!std::is_same<T, U>::value)
{
BOOST_IF_CONSTEXPR(boost::is_integral<T>::value)
BOOST_IF_CONSTEXPR(std::is_integral<T>::value)
{
return float_distance(static_cast<U>(a), b, pol);
}

View File

@@ -10,12 +10,11 @@
#pragma once
#endif
#include <type_traits>
#include <boost/math/special_functions/math_fwd.hpp>
#include <boost/math/tools/config.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/type_traits/is_constructible.hpp>
#include <boost/core/enable_if.hpp>
namespace boost{ namespace math{ namespace detail{
@@ -123,7 +122,7 @@ inline typename std::enable_if<std::is_constructible<int, T>::value, int>::type
}
template <class T, class Policy>
inline typename boost::disable_if_c<std::is_constructible<int, T>::value, int>::type
inline typename std::enable_if<!std::is_constructible<int, T>::value, int>::type
iconvert(const T& v, const Policy& pol)
{
using boost::math::itrunc;
@@ -138,7 +137,7 @@ inline typename std::enable_if<std::is_constructible<long, T>::value, long>::typ
}
template <class T, class Policy>
inline typename boost::disable_if_c<std::is_constructible<long, T>::value, long>::type
inline typename std::enable_if<!std::is_constructible<long, T>::value, long>::type
lconvert(const T& v, const Policy& pol)
{
using boost::math::ltrunc;
@@ -155,7 +154,7 @@ inline typename std::enable_if<std::is_constructible<boost::long_long_type, T>::
}
template <class T, class Policy>
inline typename boost::disable_if_c<std::is_constructible<boost::long_long_type, T>::value, boost::long_long_type>::type
inline typename std::enable_if<!std::is_constructible<boost::long_long_type, T>::value, boost::long_long_type>::type
llconvertert(const T& v, const Policy& pol)
{
using boost::math::lltrunc;

View File

@@ -11,9 +11,9 @@
#ifndef BOOST_MATH_NO_LEXICAL_CAST
#include <boost/lexical_cast.hpp>
#endif
#include <boost/type_traits/is_constructible.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_floating_point.hpp>
#include <type_traits>
#include <limits>
namespace boost{ namespace math{
@@ -73,7 +73,7 @@ inline BOOST_MATH_CONSTEXPR T make_big_value(largest_float, const char* s, std::
BOOST_STRINGIZE(x), \
std::integral_constant<bool, (std::is_convertible<boost::math::tools::largest_float, T>::value) && \
((D <= boost::math::tools::numeric_traits<boost::math::tools::largest_float>::digits) \
|| boost::is_floating_point<T>::value \
|| std::is_floating_point<T>::value \
|| (boost::math::tools::numeric_traits<T>::is_specialized && \
(boost::math::tools::numeric_traits<T>::digits10 <= boost::math::tools::numeric_traits<boost::math::tools::largest_float>::digits10))) >(), \
std::is_constructible<T, const char*>())
@@ -82,7 +82,7 @@ inline BOOST_MATH_CONSTEXPR T make_big_value(largest_float, const char* s, std::
//
#define BOOST_MATH_HUGE_CONSTANT(T, D, x)\
boost::math::tools::make_big_value<T>(0.0L, BOOST_STRINGIZE(x), \
std::integral_constant<bool, boost::is_floating_point<T>::value || (boost::math::tools::numeric_traits<T>::is_specialized && boost::math::tools::numeric_traits<T>::max_exponent <= boost::math::tools::numeric_traits<boost::math::tools::largest_float>::max_exponent && boost::math::tools::numeric_traits<T>::digits <= boost::math::tools::numeric_traits<boost::math::tools::largest_float>::digits)>(), \
std::integral_constant<bool, std::is_floating_point<T>::value || (boost::math::tools::numeric_traits<T>::is_specialized && boost::math::tools::numeric_traits<T>::max_exponent <= boost::math::tools::numeric_traits<boost::math::tools::largest_float>::max_exponent && boost::math::tools::numeric_traits<T>::digits <= boost::math::tools::numeric_traits<boost::math::tools::largest_float>::digits)>(), \
std::is_constructible<T, const char*>())
}}} // namespaces

View File

@@ -10,17 +10,25 @@
#ifndef BOOST_MATH_TOOLS_COMPLEX_HPP
#define BOOST_MATH_TOOLS_COMPLEX_HPP
#include <boost/type_traits/is_complex.hpp>
#include <utility>
#include <boost/math/tools/is_detected.hpp>
namespace boost {
namespace math {
namespace tools {
//
// Specialize this trait for user-defined complex types (ie Boost.Multiprecision):
//
template <class T>
struct is_complex_type : public boost::is_complex<T> {};
template <typename T, typename = void>
struct is_complex_type
{
static constexpr bool value = false;
};
template <typename T>
struct is_complex_type<T, void_t<decltype(std::declval<T>().real()),
decltype(std::declval<T>().imag())>>
{
static constexpr bool value = true;
};
//
// Use this trait to typecast integer literals to something
// that will interoperate with T:

View File

@@ -10,8 +10,7 @@
#pragma once
#endif
#include <boost/type_traits/is_constructible.hpp>
#include <boost/type_traits/conditional.hpp>
#include <type_traits>
#include <boost/lexical_cast.hpp>
namespace boost{ namespace math{ namespace tools{
@@ -19,7 +18,7 @@ namespace boost{ namespace math{ namespace tools{
template <class T>
struct convert_from_string_result
{
typedef typename boost::conditional<std::is_constructible<T, const char*>::value, const char*, T>::type type;
typedef typename std::conditional<std::is_constructible<T, const char*>::value, const char*, T>::type type;
};
template <class Real>

View File

@@ -9,11 +9,11 @@
#include <boost/config.hpp>
#include <boost/math/tools/cxx03_warn.hpp>
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_SFINAE_EXPR)
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
#define BOOST_MATH_HAS_IS_CONST_ITERABLE
#include <boost/type_traits/is_detected.hpp>
#include <boost/math/tools/is_detected.hpp>
#include <utility>
namespace boost {
@@ -31,9 +31,9 @@ namespace boost {
template <class T>
struct is_const_iterable
: public std::integral_constant<bool,
boost::is_detected<begin_t, T>::value
&& boost::is_detected<end_t, T>::value
&& boost::is_detected<const_iterator_t, T>::value
is_detected<begin_t, T>::value
&& is_detected<end_t, T>::value
&& is_detected<const_iterator_t, T>::value
> {};
} } } }

View File

@@ -26,6 +26,7 @@
#include <ostream>
#include <algorithm>
#include <initializer_list>
#include <type_traits>
namespace boost{ namespace math{ namespace tools{
@@ -122,7 +123,7 @@ namespace detail {
* subtlety of distinction.
*/
template <typename T, typename N>
BOOST_DEDUCED_TYPENAME disable_if_c<std::numeric_limits<T>::is_integer, void >::type
BOOST_DEDUCED_TYPENAME std::enable_if<!std::numeric_limits<T>::is_integer, void >::type
division_impl(polynomial<T> &q, polynomial<T> &u, const polynomial<T>& v, N n, N k)
{
q[k] = u[n + k] / v[n];
@@ -165,7 +166,7 @@ T integer_power(T t, N n)
* don't currently have that subtlety of distinction.
*/
template <typename T, typename N>
BOOST_DEDUCED_TYPENAME enable_if_c<std::numeric_limits<T>::is_integer, void >::type
BOOST_DEDUCED_TYPENAME std::enable_if<std::numeric_limits<T>::is_integer, void >::type
division_impl(polynomial<T> &q, polynomial<T> &u, const polynomial<T>& v, N n, N k)
{
q[k] = u[n + k] * integer_power(v[n], k);

View File

@@ -11,10 +11,10 @@
#pragma once
#endif
#include <algorithm>
#include <type_traits>
#include <boost/math/tools/polynomial.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/type_traits/is_pod.hpp>
namespace boost{
@@ -114,7 +114,7 @@ namespace detail
* @return Greatest common divisor of polynomials u and v.
*/
template <class T>
typename enable_if_c< std::numeric_limits<T>::is_integer, polynomial<T> >::type
typename std::enable_if< std::numeric_limits<T>::is_integer, polynomial<T> >::type
subresultant_gcd(polynomial<T> u, polynomial<T> v)
{
using std::swap;
@@ -167,14 +167,14 @@ subresultant_gcd(polynomial<T> u, polynomial<T> v)
* @tparam T A multi-precision integral type.
*/
template <typename T>
typename enable_if_c<std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_bounded, polynomial<T> >::type
typename std::enable_if<std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_bounded, polynomial<T> >::type
gcd(polynomial<T> const &u, polynomial<T> const &v)
{
return subresultant_gcd(u, v);
}
// GCD over bounded integers is not currently allowed:
template <typename T>
typename enable_if_c<std::numeric_limits<T>::is_integer && std::numeric_limits<T>::is_bounded, polynomial<T> >::type
typename std::enable_if<std::numeric_limits<T>::is_integer && std::numeric_limits<T>::is_bounded, polynomial<T> >::type
gcd(polynomial<T> const &u, polynomial<T> const &v)
{
static_assert(sizeof(v) == 0, "GCD on polynomials of bounded integers is disallowed due to the excessive growth in the size of intermediate terms.");
@@ -182,7 +182,7 @@ gcd(polynomial<T> const &u, polynomial<T> const &v)
}
// GCD over polynomials of floats can go via the Euclid algorithm:
template <typename T>
typename enable_if_c<!std::numeric_limits<T>::is_integer && (std::numeric_limits<T>::min_exponent != std::numeric_limits<T>::max_exponent) && !std::numeric_limits<T>::is_exact, polynomial<T> >::type
typename std::enable_if<!std::numeric_limits<T>::is_integer && (std::numeric_limits<T>::min_exponent != std::numeric_limits<T>::max_exponent) && !std::numeric_limits<T>::is_exact, polynomial<T> >::type
gcd(polynomial<T> const &u, polynomial<T> const &v)
{
return boost::integer::gcd_detail::Euclid_gcd(u, v);

View File

@@ -28,8 +28,8 @@
#include <boost/cstdfloat.hpp> // For float_64_t, float128_t. Must be first include!
#include <boost/lexical_cast.hpp>
#include <boost/type_traits/is_constructible.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <limits>
#include <type_traits>
#ifdef BOOST_MATH_INSTRUMENT_CREATE_TEST_VALUE
// global int create_type(0); must be defined before including this file.

View File

@@ -6,6 +6,7 @@
// Basic sanity check that header <boost/math/distributions/find_location.hpp>
// #includes all the files that it needs to.
//
#include <type_traits>
#include <boost/math/distributions/find_location.hpp>
//
// Note this header includes no other headers, this is
@@ -36,8 +37,8 @@ T quantile(const boost::math::complemented2_type<test_distribution<T, Policy>, T
namespace boost{ namespace math{ namespace tools{
template <class T, class Policy> struct is_distribution<test_distribution<T, Policy> > : public true_type{};
template <class T, class Policy> struct is_scaled_distribution<test_distribution<T, Policy> > : public true_type{};
template <class T, class Policy> struct is_distribution<test_distribution<T, Policy> > : public std::true_type {};
template <class T, class Policy> struct is_scaled_distribution<test_distribution<T, Policy> > : public std::true_type {};
}}}

View File

@@ -36,8 +36,8 @@ T quantile(const boost::math::complemented2_type<test_distribution<T, Policy>, T
namespace boost{ namespace math{ namespace tools{
template <class T, class Policy> struct is_distribution<test_distribution<T, Policy> > : public true_type{};
template <class T, class Policy> struct is_scaled_distribution<test_distribution<T, Policy> > : public true_type{};
template <class T, class Policy> struct is_distribution<test_distribution<T, Policy> > : public std::true_type {};
template <class T, class Policy> struct is_scaled_distribution<test_distribution<T, Policy> > : public std::true_type {};
}}}