Skip to content

Commit

Permalink
Sync from upstream.
Browse files Browse the repository at this point in the history
  • Loading branch information
grafikrobot committed Aug 9, 2024
2 parents 4207037 + 0ab75f9 commit 5641f21
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 50 deletions.
103 changes: 73 additions & 30 deletions example/float128_snips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,47 +44,90 @@ and have full `std::numeric_limits` support:
std::cout.precision(std::numeric_limits<float128>::max_digits10);
std::cout << "pi = " << pi << std::endl; //pi = 3.14159265358979323846264338327950280
//] [/float128_eg]

// Full generation for numeric limits below:
using boost::multiprecision::float128;
std::cout << std::boolalpha;
std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10);

std::cout << "GCC " << __VERSION__ << std::endl << std::endl;
std::cout << "Type name: boost::multiprecision::float128" << std::endl;
std::cout << "Full name: " << boost::typeindex::type_id<float128>().pretty_name() << std::endl << std::endl;

std::cout << "std::is_fundamental<> = " << std::is_fundamental_v<float128> << std::endl;
std::cout << "boost::multiprecision::detail::is_signed<> = " << boost::multiprecision::detail::is_signed_v<float128> << std::endl;
std::cout << "boost::multiprecision::detail::is_unsigned<> = " << boost::multiprecision::detail::is_unsigned_v<float128> << std::endl;
std::cout << "boost::multiprecision::detail::is_integral<> = " << boost::multiprecision::detail::is_integral_v<float128> << std::endl;
std::cout << "boost::multiprecision::detail::is_arithmetic<> = " << boost::multiprecision::detail::is_arithmetic_v<float128> << std::endl;
std::cout << "std::is_const<> = " << std::is_const_v<float128> << std::endl;
std::cout << "std::is_trivial<> = " << std::is_trivial_v<float128> << std::endl;
std::cout << "std::is_trivially_copyable<> = " << std::is_trivially_copyable_v<float128> << std::endl;
std::cout << "std::is_standard_layout<> = " << std::is_standard_layout_v<float128> << std::endl;
std::cout << "std::is_pod<> = " << std::is_pod_v<float128> << std::endl;
std::cout << "std::numeric_limits<>::is_exact = " << std::numeric_limits<float128>::is_exact << std::endl;
std::cout << "std::numeric_limits<>::is_bounded = " << std::numeric_limits<float128>::is_bounded << std::endl;
std::cout << "std::numeric_limits<>::is_modulo = " << std::numeric_limits<float128>::is_modulo << std::endl;
std::cout << "std::numeric_limits<>::is_iec559 = " << std::numeric_limits<float128>::is_iec559 << std::endl;
std::cout << "std::numeric_limits<>::traps = " << std::numeric_limits<float128>::traps << std::endl;
std::cout << "std::numeric_limits<>::tinyness_before = " << std::numeric_limits<float128>::tinyness_before << std::endl;
std::cout << "std::numeric_limits<>::max() = " << (std::numeric_limits<float128>::max)() << std::endl;
std::cout << "std::numeric_limits<>::min() = " << (std::numeric_limits<float128>::min)() << std::endl;
std::cout << "std::numeric_limits<>::lowest() = " << std::numeric_limits<float128>::lowest() << std::endl;
std::cout << "std::numeric_limits<>::min_exponent = " << std::numeric_limits<float128>::min_exponent << std::endl;
std::cout << "std::numeric_limits<>::max_exponent = " << std::numeric_limits<float128>::max_exponent << std::endl;
std::cout << "std::numeric_limits<>::epsilon() = " << std::numeric_limits<float128>::epsilon() << std::endl;
std::cout << "std::numeric_limits<>::radix = " << std::numeric_limits<float128>::radix << std::endl;
std::cout << "std::numeric_limits<>::digits = " << std::numeric_limits<float128>::digits << std::endl;
std::cout << "std::numeric_limits<>::max_digits10 = " << std::numeric_limits<float128>::max_digits10 << std::endl;
std::cout << "std::numeric_limits<>::has_denorm = " << std::numeric_limits<float128>::has_denorm << std::endl;
std::cout << "std::numeric_limits<>::denorm_min() = " << std::numeric_limits<float128>::denorm_min() << std::endl;
std::cout << "std::numeric_limits<>::has_denorm_loss = " << std::numeric_limits<float128>::has_denorm_loss << std::endl;
std::cout << "std::numeric_limits<>::has_signaling_NaN = " << std::numeric_limits<float128>::has_signaling_NaN << std::endl;
std::cout << "std::numeric_limits<>::quiet_NaN() = " << std::numeric_limits<float128>::quiet_NaN() << std::endl;
std::cout << "std::numeric_limits<>::infinity() = " << std::numeric_limits<float128>::infinity() << std::endl;

return 0;
}

/*
//[float128_numeric_limits
GCC 8.1.0
GCC 14.1.0
Type name: boost::multiprecision::float128
Full name: boost::multiprecision::number<boost::multiprecision::backends::float128_backend, (boost::multiprecision::expression_template_option)0>
Type name is float128_t:
Type is g
std::is_fundamental<> = true
boost::multiprecision::detail::is_signed<> = true
std::is_fundamental<> = false
boost::multiprecision::detail::is_signed<> = false
boost::multiprecision::detail::is_unsigned<> = false
boost::multiprecision::detail::is_integral<> = false
boost::multiprecision::detail::is_arithmetic<> = true
boost::multiprecision::detail::is_arithmetic<> = false
std::is_const<> = false
std::is_trivial<> = true
std::is_trivial<> = false
std::is_trivially_copyable<> = true
std::is_standard_layout<> = true
std::is_pod<> = true
std::numeric_limits::<>is_exact = false
std::numeric_limits::<>is bounded = true
std::numeric_limits::<>is_modulo = false
std::numeric_limits::<>is_iec559 = true
std::numeric_limits::<>traps = false
std::numeric_limits::<>tinyness_before = false
std::numeric_limits::<>max() = 1.18973149535723176508575932662800702e+4932
std::numeric_limits::<>min() = 3.36210314311209350626267781732175260e-4932
std::numeric_limits::<>lowest() = -1.18973149535723176508575932662800702e+4932
std::numeric_limits::<>min_exponent = -16381
std::numeric_limits::<>max_exponent = 16384
std::numeric_limits::<>epsilon() = 1.92592994438723585305597794258492732e-34
std::numeric_limits::<>radix = 2
std::numeric_limits::<>digits = 113
std::numeric_limits::<>digits10 = 33
std::numeric_limits::<>max_digits10 = 36
std::numeric_limits::<>has denorm = true
std::numeric_limits::<>denorm min = 6.47517511943802511092443895822764655e-4966
std::denorm_loss = false
limits::has_signaling_NaN == false
std::numeric_limits::<>quiet_NaN = nan
std::numeric_limits::<>infinity = inf
std::is_pod<> = false
std::numeric_limits<>::is_exact = false
std::numeric_limits<>::is_bounded = true
std::numeric_limits<>::is_modulo = false
std::numeric_limits<>::is_iec559 = true
std::numeric_limits<>::traps = false
std::numeric_limits<>::tinyness_before = false
std::numeric_limits<>::max() = 1.18973149535723176508575932662800702e+4932
std::numeric_limits<>::min() = 3.3621031431120935062626778173217526e-4932
std::numeric_limits<>::lowest() = -1.18973149535723176508575932662800702e+4932
std::numeric_limits<>::min_exponent = -16381
std::numeric_limits<>::max_exponent = 16384
std::numeric_limits<>::epsilon() = 1.92592994438723585305597794258492732e-34
std::numeric_limits<>::radix = 2
std::numeric_limits<>::digits = 113
std::numeric_limits<>::max_digits10 = 36
std::numeric_limits<>::has_denorm = 1
std::numeric_limits<>::denorm_min() = 6.47517511943802511092443895822764655e-4966
std::numeric_limits<>::has_denorm_loss = true
std::numeric_limits<>::has_signaling_NaN = false
std::numeric_limits<>::quiet_NaN() = nan
std::numeric_limits<>::infinity() = inf
//] [/float128_numeric_limits]
*/
Expand Down
9 changes: 3 additions & 6 deletions include/boost/multiprecision/float128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,9 @@ struct float128_backend

public:
constexpr float128_backend() noexcept : m_value(0) {}
constexpr float128_backend(const float128_backend& o) noexcept : m_value(o.m_value) {}
BOOST_MP_CXX14_CONSTEXPR float128_backend& operator=(const float128_backend& o) noexcept
{
m_value = o.m_value;
return *this;
}
constexpr float128_backend(const float128_backend& o) noexcept = default;
BOOST_MP_CXX14_CONSTEXPR float128_backend& operator=(const float128_backend& o) noexcept = default;

template <class T>
constexpr float128_backend(const T& i, const typename std::enable_if<std::is_convertible<T, float128_type>::value>::type* = nullptr) noexcept(noexcept(std::declval<float128_type&>() = std::declval<const T&>()))
: m_value(i) {}
Expand Down
19 changes: 5 additions & 14 deletions include/boost/multiprecision/number.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class number
static constexpr expression_template_option et = ExpressionTemplates;

BOOST_MP_FORCEINLINE constexpr number() noexcept(noexcept(Backend())) {}
BOOST_MP_FORCEINLINE constexpr number(const number& e) noexcept(noexcept(Backend(std::declval<Backend const&>()))) : m_backend(e.m_backend) {}
BOOST_MP_FORCEINLINE constexpr number(const number& e) noexcept(noexcept(Backend(std::declval<Backend const&>()))) = default;
template <class V>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number(const V& v,
typename std::enable_if<
Expand Down Expand Up @@ -372,11 +372,7 @@ class number
}

BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number& operator=(const number& e)
noexcept(noexcept(std::declval<Backend&>() = std::declval<Backend const&>()))
{
m_backend = e.m_backend;
return *this;
}
noexcept(noexcept(std::declval<Backend&>() = std::declval<Backend const&>())) = default;

template <class V>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<std::is_convertible<V, self_type>::value, number<Backend, ExpressionTemplates>&>::type
Expand Down Expand Up @@ -451,14 +447,9 @@ class number

// rvalues:
BOOST_MP_FORCEINLINE constexpr number(number&& r)
noexcept(noexcept(Backend(std::declval<Backend>())))
: m_backend(static_cast<Backend&&>(r.m_backend))
{}
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number& operator=(number&& r) noexcept(noexcept(std::declval<Backend&>() = std::declval<Backend>()))
{
m_backend = static_cast<Backend&&>(r.m_backend);
return *this;
}
noexcept(noexcept(Backend(std::declval<Backend>()))) = default;
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number& operator=(number&& r) noexcept(noexcept(std::declval<Backend&>() = std::declval<Backend>())) = default;

template <class Other, expression_template_option ET>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number(number<Other, ET>&& val,
typename std::enable_if<(std::is_convertible<Other, Backend>::value && !detail::is_restricted_conversion<Other, Backend>::value)>::type* = nullptr)
Expand Down
1 change: 1 addition & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,7 @@ test-suite misc :
[ compile git_issue_608.cpp ]
[ run git_issue_624.cpp ]
[ run git_issue_626.cpp ]
[ run git_issue_636.cpp : : : [ check-target-builds ../config//has_float128 : <source>quadmath : <build>no ] ]
[ compile git_issue_98.cpp :
[ check-target-builds ../config//has_float128 : <define>TEST_FLOAT128 <source>quadmath : ]
[ check-target-builds ../config//has_gmp : <define>TEST_GMP <source>gmp : ]
Expand Down
15 changes: 15 additions & 0 deletions test/git_issue_636.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright 2024 Matt Borland. Distributed under 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)
//
// See: https://github.com/boostorg/multiprecision/issues/635

#include <boost/multiprecision/float128.hpp>
#include <type_traits>

int main()
{
static_assert(std::is_trivially_copyable<boost::multiprecision::float128>::value, "Should be trivial now");
return 0;
}

0 comments on commit 5641f21

Please sign in to comment.