diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-04-08 03:09:47 +0000 |
---|---|---|
committer | <> | 2015-05-05 14:37:32 +0000 |
commit | f2541bb90af059680aa7036f315f052175999355 (patch) | |
tree | a5b214744b256f07e1dc2bd7273035a7808c659f /libs/multiprecision/test | |
parent | ed232fdd34968697a68783b3195b1da4226915b5 (diff) | |
download | boost-tarball-master.tar.gz |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'libs/multiprecision/test')
-rw-r--r-- | libs/multiprecision/test/Jamfile.v2 | 8 | ||||
-rw-r--r-- | libs/multiprecision/test/test_nothrow_cpp_bin_float.cpp | 53 | ||||
-rw-r--r-- | libs/multiprecision/test/test_nothrow_cpp_dec_float.cpp | 53 | ||||
-rw-r--r-- | libs/multiprecision/test/test_nothrow_cpp_int.cpp | 250 | ||||
-rw-r--r-- | libs/multiprecision/test/test_nothrow_cpp_rational.cpp | 208 | ||||
-rw-r--r-- | libs/multiprecision/test/test_nothrow_float128.cpp | 53 | ||||
-rw-r--r-- | libs/multiprecision/test/test_nothrow_gmp.cpp | 38 | ||||
-rw-r--r-- | libs/multiprecision/test/test_nothrow_mpfr.cpp | 36 |
8 files changed, 699 insertions, 0 deletions
diff --git a/libs/multiprecision/test/Jamfile.v2 b/libs/multiprecision/test/Jamfile.v2 index 5972b7762..0ec5ea08b 100644 --- a/libs/multiprecision/test/Jamfile.v2 +++ b/libs/multiprecision/test/Jamfile.v2 @@ -350,6 +350,14 @@ compile test_constexpr.cpp : [ check-target-builds ../config//has_intel_quad : <cxxflags>-Qoption,cpp,--extended_float_type <define>HAVE_FLOAT128 : ] [ requires cxx11_constexpr cxx11_user_defined_literals ] ; +compile test_nothrow_cpp_int.cpp ; +compile test_nothrow_cpp_rational.cpp ; +compile test_nothrow_cpp_bin_float.cpp ; +compile test_nothrow_cpp_dec_float.cpp ; +compile test_nothrow_float128.cpp : [ check-target-builds ../config//has_float128 : : <build>no ] ; +compile test_nothrow_gmp.cpp : [ check-target-builds ../config//has_gmp : : <build>no ] ; +compile test_nothrow_mpfr.cpp : [ check-target-builds ../config//has_mpfr : : <build>no ] ; + run test_cpp_bin_float_io.cpp /boost/system//boost_system /boost/chrono//boost_chrono : # command line : # input files diff --git a/libs/multiprecision/test/test_nothrow_cpp_bin_float.cpp b/libs/multiprecision/test/test_nothrow_cpp_bin_float.cpp new file mode 100644 index 000000000..91859ca89 --- /dev/null +++ b/libs/multiprecision/test/test_nothrow_cpp_bin_float.cpp @@ -0,0 +1,53 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. 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) + +#include <boost/multiprecision/cpp_bin_float.hpp> +#include <boost/type_traits/is_nothrow_move_constructible.hpp> +#include <boost/type_traits/is_nothrow_move_assignable.hpp> +#include <boost/type_traits/has_nothrow_constructor.hpp> +#include <boost/type_traits/has_nothrow_assign.hpp> +#include <boost/type_traits/has_nothrow_copy.hpp> +#include <boost/static_assert.hpp> + +#ifndef BOOST_NO_NOEXCEPT + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_CONSTRUCT) +// +// Move construct: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::cpp_bin_float_100>::value); + +#endif + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_ASSIGN) +// +// Move assign: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::cpp_bin_float_100>::value); + +#endif + +// +// Construct: +// +#ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::cpp_bin_float_100>::value); +#endif +// +// Copy construct: +// +#ifdef BOOST_HAS_NOTHROW_COPY +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<boost::multiprecision::cpp_bin_float_100>::value); +#endif +// +// Assign: +// +#ifdef BOOST_HAS_NOTHROW_ASSIGN +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<boost::multiprecision::cpp_bin_float_100>::value); +#endif + +#endif // noexcept + + diff --git a/libs/multiprecision/test/test_nothrow_cpp_dec_float.cpp b/libs/multiprecision/test/test_nothrow_cpp_dec_float.cpp new file mode 100644 index 000000000..1e522648f --- /dev/null +++ b/libs/multiprecision/test/test_nothrow_cpp_dec_float.cpp @@ -0,0 +1,53 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. 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) + +#include <boost/multiprecision/cpp_dec_float.hpp> +#include <boost/type_traits/is_nothrow_move_constructible.hpp> +#include <boost/type_traits/is_nothrow_move_assignable.hpp> +#include <boost/type_traits/has_nothrow_constructor.hpp> +#include <boost/type_traits/has_nothrow_assign.hpp> +#include <boost/type_traits/has_nothrow_copy.hpp> +#include <boost/static_assert.hpp> + +#ifndef BOOST_NO_NOEXCEPT + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_CONSTRUCT) +// +// Move construct: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::cpp_dec_float_100>::value); + +#endif + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_ASSIGN) +// +// Move assign: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::cpp_dec_float_100>::value); + +#endif + +// +// Construct: +// +#ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::cpp_dec_float_100>::value); +#endif +// +// Copy construct: +// +#ifdef BOOST_HAS_NOTHROW_COPY +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<boost::multiprecision::cpp_dec_float_100>::value); +#endif +// +// Assign: +// +#ifdef BOOST_HAS_NOTHROW_ASSIGN +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<boost::multiprecision::cpp_dec_float_100>::value); +#endif + +#endif // noexcept + + diff --git a/libs/multiprecision/test/test_nothrow_cpp_int.cpp b/libs/multiprecision/test/test_nothrow_cpp_int.cpp new file mode 100644 index 000000000..89045bcbe --- /dev/null +++ b/libs/multiprecision/test/test_nothrow_cpp_int.cpp @@ -0,0 +1,250 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2std::declval<boost::multiprecision::signed_limb_type>()15 John Maddock. Distributed under the Boost +// Software License, Version 1.std::declval<boost::multiprecision::signed_limb_type>(). (See accompanying file +// LICENSE_1_std::declval<boost::multiprecision::signed_limb_type>().txt or copy at http://www.boost.org/LICENSE_1_std::declval<boost::multiprecision::signed_limb_type>().txt) + +#include <boost/multiprecision/cpp_int.hpp> +#include <boost/type_traits/is_nothrow_move_constructible.hpp> +#include <boost/type_traits/is_nothrow_move_assignable.hpp> +#include <boost/type_traits/has_nothrow_constructor.hpp> +#include <boost/type_traits/has_nothrow_assign.hpp> +#include <boost/type_traits/has_nothrow_copy.hpp> +#include <boost/static_assert.hpp> + +#ifndef BOOST_NO_NOEXCEPT + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_CONSTRUCT) +// +// Move construct: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::cpp_int>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::int128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::checked_int128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::uint128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::checked_uint128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::int512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::checked_int512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::uint512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::checked_uint512_t>::value); + +#endif + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_ASSIGN) +// +// Move assign: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::cpp_int>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::int128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::checked_int128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::uint128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::checked_uint128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::int512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::checked_int512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::uint512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::checked_uint512_t>::value); + +#endif + +// +// Construct: +// +#ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::cpp_int>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::int128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::checked_int128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::uint128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::checked_uint128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::int512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::checked_int512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::uint512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::checked_uint512_t>::value); +#endif +// +// Copy construct: +// +#ifdef BOOST_HAS_NOTHROW_COPY +BOOST_STATIC_ASSERT(!boost::has_nothrow_copy<boost::multiprecision::cpp_int>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<boost::multiprecision::int128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<boost::multiprecision::checked_int128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<boost::multiprecision::uint128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<boost::multiprecision::checked_uint128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<boost::multiprecision::int512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<boost::multiprecision::checked_int512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<boost::multiprecision::uint512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<boost::multiprecision::checked_uint512_t>::value); +#endif +// +// Assign: +// +#ifdef BOOST_HAS_NOTHROW_ASSIGN +BOOST_STATIC_ASSERT(!boost::has_nothrow_assign<boost::multiprecision::cpp_int>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<boost::multiprecision::int128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<boost::multiprecision::checked_int128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<boost::multiprecision::uint128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<boost::multiprecision::checked_uint128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<boost::multiprecision::int512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<boost::multiprecision::checked_int512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<boost::multiprecision::uint512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<boost::multiprecision::checked_uint512_t>::value); +#endif +// +// Construct from int: +// +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::cpp_int(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::int128_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::checked_int128_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::uint128_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(!noexcept(boost::multiprecision::checked_uint128_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::int512_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::checked_int512_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::uint512_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(!noexcept(boost::multiprecision::checked_uint512_t(std::declval<boost::multiprecision::signed_limb_type>()))); +// +// Construct from unsigned int: +// +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::cpp_int(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::int128_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::checked_int128_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::uint128_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::checked_uint128_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::int512_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::checked_int512_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::uint512_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::checked_uint512_t(std::declval<boost::multiprecision::limb_type>()))); +// +// Assign from int: +// +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::cpp_int>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::int128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::checked_int128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::uint128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<boost::multiprecision::checked_uint128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::int512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::checked_int512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::uint512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<boost::multiprecision::checked_uint512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +// +// Assign from unsigned int: +// +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::cpp_int>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::int128_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::checked_int128_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::uint128_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::checked_uint128_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::int512_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::checked_int512_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::uint512_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::checked_uint512_t>() = std::declval<boost::multiprecision::limb_type>())); + +#if defined(BOOST_LITTLE_ENDIAN) +// +// We can also nothrow construct from a double_limb_type (or smaller obviously) as long as double_limb_type is smaller than the type +// in question (so don't test 128-bit integers in case double_limb_type is __int128). +// +// Construct from int: +// +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::cpp_int(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::int512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::checked_int512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::uint512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(!noexcept(boost::multiprecision::checked_uint512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +// +// Construct from unsigned int: +// +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::cpp_int(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::int512_t(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::checked_int512_t(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::uint512_t(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::checked_uint512_t(std::declval<boost::multiprecision::double_limb_type>()))); +// +// Assign from int: +// +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::cpp_int>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::int512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::checked_int512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::uint512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<boost::multiprecision::checked_uint512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +// +// Assign from unsigned int: +// +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::cpp_int>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::int512_t>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::checked_int512_t>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::uint512_t>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::checked_uint512_t>() = std::declval<boost::multiprecision::double_limb_type>())); + +#endif // little endian + +typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<32, 32, boost::multiprecision::signed_magnitude, boost::multiprecision::checked, void> > checked_int32_t; +typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<32, 32, boost::multiprecision::unsigned_magnitude, boost::multiprecision::checked, void> > checked_uint32_t; +typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<32, 32, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void> > unchecked_int32_t; +typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<32, 32, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void> > unchecked_uint32_t; + +// +// Construct from int: +// +BOOST_STATIC_ASSERT(noexcept(unchecked_int32_t(std::declval<boost::int32_t>()))); +BOOST_STATIC_ASSERT(noexcept(checked_int32_t(std::declval<boost::int32_t>()))); +BOOST_STATIC_ASSERT(noexcept(unchecked_uint32_t(std::declval<boost::int32_t>()))); +BOOST_STATIC_ASSERT(!noexcept(checked_uint32_t(std::declval<boost::int32_t>()))); +// +// Construct from unsigned int: +// +BOOST_STATIC_ASSERT(noexcept(unchecked_int32_t(std::declval<boost::uint32_t>()))); +BOOST_STATIC_ASSERT(noexcept(checked_int32_t(std::declval<boost::uint32_t>()))); +BOOST_STATIC_ASSERT(noexcept(unchecked_uint32_t(std::declval<boost::uint32_t>()))); +BOOST_STATIC_ASSERT(noexcept(checked_uint32_t(std::declval<boost::uint32_t>()))); +// +// Assign from int: +// +BOOST_STATIC_ASSERT(noexcept(std::declval<unchecked_int32_t>() = std::declval<boost::int32_t>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_int32_t>() = std::declval<boost::int32_t>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<unchecked_uint32_t>() = std::declval<boost::int32_t>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_uint32_t>() = std::declval<boost::int32_t>())); +// +// Assign from unsigned int: +// +BOOST_STATIC_ASSERT(noexcept(std::declval<unchecked_int32_t>() = std::declval<boost::uint32_t>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_int32_t>() = std::declval<boost::uint32_t>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<unchecked_uint32_t>() = std::declval<boost::uint32_t>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_uint32_t>() = std::declval<boost::uint32_t>())); + +// +// And finally some things which should *not* be noexcept: +// +typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<30, 30, boost::multiprecision::signed_magnitude, boost::multiprecision::checked, void> > checked_int30_t; +typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<30, 30, boost::multiprecision::unsigned_magnitude, boost::multiprecision::checked, void> > checked_uint30_t; +typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<30, 30, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void> > unchecked_int30_t; +typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<30, 30, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void> > unchecked_uint30_t; + +// +// Construct from int: +// +BOOST_STATIC_ASSERT(!noexcept(checked_int30_t(std::declval<boost::int32_t>()))); +BOOST_STATIC_ASSERT(!noexcept(checked_uint30_t(std::declval<boost::int32_t>()))); +BOOST_STATIC_ASSERT(!noexcept(checked_int32_t(std::declval<boost::int64_t>()))); +BOOST_STATIC_ASSERT(!noexcept(checked_uint32_t(std::declval<boost::int64_t>()))); +// +// Construct from unsigned int: +// +BOOST_STATIC_ASSERT(!noexcept(checked_int30_t(std::declval<boost::uint32_t>()))); +BOOST_STATIC_ASSERT(!noexcept(checked_uint30_t(std::declval<boost::uint32_t>()))); +BOOST_STATIC_ASSERT(!noexcept(checked_int32_t(std::declval<boost::uint64_t>()))); +BOOST_STATIC_ASSERT(!noexcept(checked_uint32_t(std::declval<boost::uint64_t>()))); +// +// Assign from int: +// +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_int30_t>() = std::declval<boost::int32_t>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_uint30_t>() = std::declval<boost::int32_t>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_int32_t>() = std::declval<boost::int64_t>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_uint32_t>() = std::declval<boost::int64_t>())); +// +// Assign from unsigned int: +// +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_int30_t>() = std::declval<boost::uint32_t>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_uint30_t>() = std::declval<boost::uint32_t>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_int32_t>() = std::declval<boost::uint64_t>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_uint32_t>() = std::declval<boost::uint64_t>())); + +#endif // noexcept + diff --git a/libs/multiprecision/test/test_nothrow_cpp_rational.cpp b/libs/multiprecision/test/test_nothrow_cpp_rational.cpp new file mode 100644 index 000000000..a6949fb75 --- /dev/null +++ b/libs/multiprecision/test/test_nothrow_cpp_rational.cpp @@ -0,0 +1,208 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. 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) + +#include <boost/multiprecision/cpp_int.hpp> +#include <boost/type_traits/is_nothrow_move_constructible.hpp> +#include <boost/type_traits/is_nothrow_move_assignable.hpp> +#include <boost/type_traits/has_nothrow_constructor.hpp> +#include <boost/type_traits/has_nothrow_assign.hpp> +#include <boost/type_traits/has_nothrow_copy.hpp> +#include <boost/static_assert.hpp> + +typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::int128_t::backend_type> > rat128_t; +typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::uint128_t::backend_type> > urat128_t; +typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::int512_t::backend_type> > rat512_t; +typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::uint512_t::backend_type> > urat512_t; + +typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::checked_int128_t::backend_type> > checked_rat128_t; +typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::checked_uint128_t::backend_type> > checked_urat128_t; +typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::checked_int512_t::backend_type> > checked_rat512_t; +typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::checked_uint512_t::backend_type> > checked_urat512_t; + +#ifndef BOOST_NO_NOEXCEPT + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_CONSTRUCT) +// +// Move construct: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::cpp_rational>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<rat128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<checked_rat128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<urat128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<checked_urat128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<rat512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<checked_rat512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<urat512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<checked_urat512_t>::value); + +#endif + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_ASSIGN) +// +// Move assign: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::cpp_rational>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<rat128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<checked_rat128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<urat128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<checked_urat128_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<rat512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<checked_rat512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<urat512_t>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<checked_urat512_t>::value); + +#endif + +#if 0 +// +// Everything below could/should be made to work, given modifications to Boost.Rational +// + + +// +// Construct: +// +#ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::cpp_rational>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<rat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<checked_rat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<urat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<checked_urat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<rat512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<checked_rat512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<urat512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<checked_urat512_t>::value); +#endif +// +// Copy construct: +// +#ifdef BOOST_HAS_NOTHROW_COPY +BOOST_STATIC_ASSERT(!boost::has_nothrow_copy<boost::multiprecision::cpp_rational>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<rat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<checked_rat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<urat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<checked_urat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<rat512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<checked_rat512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<urat512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<checked_urat512_t>::value); +#endif +// +// Assign: +// +#ifdef BOOST_HAS_NOTHROW_ASSIGN +BOOST_STATIC_ASSERT(!boost::has_nothrow_assign<boost::multiprecision::cpp_rational>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<rat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<checked_rat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<urat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<checked_urat128_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<rat512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<checked_rat512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<urat512_t>::value); +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<checked_urat512_t>::value); +#endif +// +// Construct from int: +// +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::cpp_rational(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(rat128_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_rat128_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(urat128_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(!noexcept(checked_urat128_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(rat512_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_rat512_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(urat512_t(std::declval<boost::multiprecision::signed_limb_type>()))); +BOOST_STATIC_ASSERT(!noexcept(checked_urat512_t(std::declval<boost::multiprecision::signed_limb_type>()))); +// +// Construct from unsigned int: +// +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::cpp_rational(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(rat128_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_rat128_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(urat128_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_urat128_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(rat512_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_rat512_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(urat512_t(std::declval<boost::multiprecision::limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_urat512_t(std::declval<boost::multiprecision::limb_type>()))); +// +// Assign from int: +// +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::cpp_rational>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<rat128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_rat128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<urat128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_urat128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<rat512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_rat512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<urat512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_urat512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); +// +// Assign from unsigned int: +// +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::cpp_rational>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<rat128_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_rat128_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<urat128_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_urat128_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<rat512_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_rat512_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<urat512_t>() = std::declval<boost::multiprecision::limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_urat512_t>() = std::declval<boost::multiprecision::limb_type>())); + +#if defined(BOOST_LITTLE_ENDIAN) +// +// Construct from int: +// +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::cpp_rational(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(rat128_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_rat128_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(urat128_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(!noexcept(checked_urat128_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(rat512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_rat512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(urat512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +BOOST_STATIC_ASSERT(!noexcept(checked_urat512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); +// +// Construct from unsigned int: +// +BOOST_STATIC_ASSERT(noexcept(boost::multiprecision::cpp_rational(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(rat128_t(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_rat128_t(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(urat128_t(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_urat128_t(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(rat512_t(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_rat512_t(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(urat512_t(std::declval<boost::multiprecision::double_limb_type>()))); +BOOST_STATIC_ASSERT(noexcept(checked_urat512_t(std::declval<boost::multiprecision::double_limb_type>()))); +// +// Assign from int: +// +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::cpp_rational>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<rat128_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_rat128_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<urat128_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_urat128_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<rat512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_rat512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<urat512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +BOOST_STATIC_ASSERT(!noexcept(std::declval<checked_urat512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); +// +// Assign from unsigned int: +// +BOOST_STATIC_ASSERT(noexcept(std::declval<boost::multiprecision::cpp_rational>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<rat128_t>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_rat128_t>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<urat128_t>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_urat128_t>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<rat512_t>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_rat512_t>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<urat512_t>() = std::declval<boost::multiprecision::double_limb_type>())); +BOOST_STATIC_ASSERT(noexcept(std::declval<checked_urat512_t>() = std::declval<boost::multiprecision::double_limb_type>())); + +#endif +#endif // little endian +#endif // noexcept + diff --git a/libs/multiprecision/test/test_nothrow_float128.cpp b/libs/multiprecision/test/test_nothrow_float128.cpp new file mode 100644 index 000000000..921880e5e --- /dev/null +++ b/libs/multiprecision/test/test_nothrow_float128.cpp @@ -0,0 +1,53 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. 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) + +#include <boost/multiprecision/float128.hpp> +#include <boost/type_traits/is_nothrow_move_constructible.hpp> +#include <boost/type_traits/is_nothrow_move_assignable.hpp> +#include <boost/type_traits/has_nothrow_constructor.hpp> +#include <boost/type_traits/has_nothrow_assign.hpp> +#include <boost/type_traits/has_nothrow_copy.hpp> +#include <boost/static_assert.hpp> + +#ifndef BOOST_NO_NOEXCEPT + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_CONSTRUCT) +// +// Move construct: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::float128>::value); + +#endif + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_ASSIGN) +// +// Move assign: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::float128>::value); + +#endif + +// +// Construct: +// +#ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR +BOOST_STATIC_ASSERT(boost::has_nothrow_constructor<boost::multiprecision::float128>::value); +#endif +// +// Copy construct: +// +#ifdef BOOST_HAS_NOTHROW_COPY +BOOST_STATIC_ASSERT(boost::has_nothrow_copy<boost::multiprecision::float128>::value); +#endif +// +// Assign: +// +#ifdef BOOST_HAS_NOTHROW_ASSIGN +BOOST_STATIC_ASSERT(boost::has_nothrow_assign<boost::multiprecision::float128>::value); +#endif + +#endif // noexcept + + diff --git a/libs/multiprecision/test/test_nothrow_gmp.cpp b/libs/multiprecision/test/test_nothrow_gmp.cpp new file mode 100644 index 000000000..3c48d5b30 --- /dev/null +++ b/libs/multiprecision/test/test_nothrow_gmp.cpp @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. 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) + +#include <boost/multiprecision/gmp.hpp> +#include <boost/type_traits/is_nothrow_move_constructible.hpp> +#include <boost/type_traits/is_nothrow_move_assignable.hpp> +#include <boost/type_traits/has_nothrow_constructor.hpp> +#include <boost/type_traits/has_nothrow_assign.hpp> +#include <boost/type_traits/has_nothrow_copy.hpp> +#include <boost/static_assert.hpp> + +#ifndef BOOST_NO_NOEXCEPT + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_CONSTRUCT) +// +// Move construct: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::mpz_int>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::mpq_rational>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::mpf_float>::value); + +#endif + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_ASSIGN) +// +// Move assign: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::mpz_int>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::mpq_rational>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::mpf_float>::value); + +#endif + +#endif // noexcept + + diff --git a/libs/multiprecision/test/test_nothrow_mpfr.cpp b/libs/multiprecision/test/test_nothrow_mpfr.cpp new file mode 100644 index 000000000..40de45ede --- /dev/null +++ b/libs/multiprecision/test/test_nothrow_mpfr.cpp @@ -0,0 +1,36 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. 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) + +#include <boost/multiprecision/mpfr.hpp> +#include <boost/type_traits/is_nothrow_move_constructible.hpp> +#include <boost/type_traits/is_nothrow_move_assignable.hpp> +#include <boost/type_traits/has_nothrow_constructor.hpp> +#include <boost/type_traits/has_nothrow_assign.hpp> +#include <boost/type_traits/has_nothrow_copy.hpp> +#include <boost/static_assert.hpp> + +#ifndef BOOST_NO_NOEXCEPT + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_CONSTRUCT) +// +// Move construct: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::mpfr_float>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_constructible<boost::multiprecision::mpfr_float_100>::value); + +#endif + +#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_IS_NOTHROW_MOVE_ASSIGN) +// +// Move assign: +// +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::mpfr_float>::value); +BOOST_STATIC_ASSERT(boost::is_nothrow_move_assignable<boost::multiprecision::mpfr_float_100>::value); + +#endif + +#endif // noexcept + + |