#include <boost/static_assert.hpp>
#include <boost/assert.hpp>
-namespace boost{ namespace multiprecision{
+namespace boost {
+namespace multiprecision {
-namespace detail{
+namespace detail {
//
// These traits calculate the largest type in the list
struct largest_signed_type
{
typedef typename mpl::if_c<
- 1 + std::numeric_limits<boost::long_long_type>::digits == N,
- boost::long_long_type,
- typename mpl::if_c<
- 1 + std::numeric_limits<long>::digits == N,
- long,
- typename mpl::if_c<
- 1 + std::numeric_limits<int>::digits == N,
- int,
- typename boost::int_t<N>::exact
- >::type
- >::type
- >::type type;
+ 1 + std::numeric_limits<boost::long_long_type>::digits == N,
+ boost::long_long_type,
+ typename mpl::if_c<
+ 1 + std::numeric_limits<long>::digits == N,
+ long,
+ typename mpl::if_c<
+ 1 + std::numeric_limits<int>::digits == N,
+ int,
+ typename boost::int_t<N>::exact>::type>::type>::type type;
};
template <unsigned N>
struct largest_unsigned_type
{
typedef typename mpl::if_c<
- std::numeric_limits<boost::ulong_long_type>::digits == N,
- boost::ulong_long_type,
- typename mpl::if_c<
- std::numeric_limits<unsigned long>::digits == N,
- unsigned long,
- typename mpl::if_c<
- std::numeric_limits<unsigned int>::digits == N,
- unsigned int,
- typename boost::uint_t<N>::exact
- >::type
- >::type
- >::type type;
+ std::numeric_limits<boost::ulong_long_type>::digits == N,
+ boost::ulong_long_type,
+ typename mpl::if_c<
+ std::numeric_limits<unsigned long>::digits == N,
+ unsigned long,
+ typename mpl::if_c<
+ std::numeric_limits<unsigned int>::digits == N,
+ unsigned int,
+ typename boost::uint_t<N>::exact>::type>::type>::type type;
};
} // namespace detail
#if defined(BOOST_HAS_INT128)
typedef detail::largest_unsigned_type<64>::type limb_type;
-typedef detail::largest_signed_type<64>::type signed_limb_type;
-typedef boost::uint128_type double_limb_type;
-typedef boost::int128_type signed_double_limb_type;
-static const limb_type max_block_10 = 1000000000000000000uLL;
-static const limb_type digits_per_block_10 = 18;
+typedef detail::largest_signed_type<64>::type signed_limb_type;
+typedef boost::uint128_type double_limb_type;
+typedef boost::int128_type signed_double_limb_type;
+static const limb_type max_block_10 = 1000000000000000000uLL;
+static const limb_type digits_per_block_10 = 18;
-inline limb_type block_multiplier(unsigned count)
+inline BOOST_MP_CXX14_CONSTEXPR limb_type block_multiplier(unsigned count)
{
- static const limb_type values[digits_per_block_10]
- = { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000, 10000000000000000, 100000000000000000, 1000000000000000000 };
+#ifdef BOOST_NO_CXX14_CONSTEXPR
+ static
+#else
+ constexpr
+#endif
+ const limb_type values[digits_per_block_10] = {10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000, 10000000000000000, 100000000000000000, 1000000000000000000};
BOOST_ASSERT(count < digits_per_block_10);
return values[count];
}
// Need to specialise integer_traits for __int128 as it's not a normal native type:
} // namespace multiprecision
-template<>
+template <>
class integer_traits<multiprecision::double_limb_type>
- : public std::numeric_limits<multiprecision::double_limb_type>,
- public detail::integer_traits_base<multiprecision::double_limb_type, 0, ~static_cast<multiprecision::double_limb_type>(0)>
-{ };
-template<>
+ : public std::numeric_limits<multiprecision::double_limb_type>,
+ public detail::integer_traits_base<multiprecision::double_limb_type, 0, ~static_cast<multiprecision::double_limb_type>(0)>
+{};
+template <>
class integer_traits<multiprecision::signed_double_limb_type>
- : public std::numeric_limits<multiprecision::signed_double_limb_type>,
- public detail::integer_traits_base<multiprecision::signed_double_limb_type, static_cast<multiprecision::signed_double_limb_type>((static_cast<multiprecision::double_limb_type>(1) << 127)), static_cast<multiprecision::signed_double_limb_type>(((~static_cast<multiprecision::double_limb_type>(0)) >> 1))>
-{ };
+ : public std::numeric_limits<multiprecision::signed_double_limb_type>,
+ public detail::integer_traits_base<multiprecision::signed_double_limb_type, static_cast<multiprecision::signed_double_limb_type>((static_cast<multiprecision::double_limb_type>(1) << 127)), static_cast<multiprecision::signed_double_limb_type>(((~static_cast<multiprecision::double_limb_type>(0)) >> 1))>
+{};
-namespace multiprecision{
+namespace multiprecision {
#else
typedef detail::largest_unsigned_type<32>::type limb_type;
-typedef detail::largest_signed_type<32>::type signed_limb_type;
+typedef detail::largest_signed_type<32>::type signed_limb_type;
typedef detail::largest_unsigned_type<64>::type double_limb_type;
-typedef detail::largest_signed_type<64>::type signed_double_limb_type;
-static const limb_type max_block_10 = 1000000000;
-static const limb_type digits_per_block_10 = 9;
+typedef detail::largest_signed_type<64>::type signed_double_limb_type;
+static const limb_type max_block_10 = 1000000000;
+static const limb_type digits_per_block_10 = 9;
inline limb_type block_multiplier(unsigned count)
{
- static const limb_type values[digits_per_block_10]
- = { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
+#ifdef BOOST_NO_CXX14_CONSTEXPR
+ static
+#else
+ constexpr
+#endif
+ const limb_type values[digits_per_block_10] = {10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
BOOST_ASSERT(count < digits_per_block_10);
return values[count];
}
static const unsigned bits_per_limb = sizeof(limb_type) * CHAR_BIT;
template <class T>
-inline void minmax(const T& a, const T& b, T& aa, T& bb)
+inline BOOST_MP_CXX14_CONSTEXPR void minmax(const T& a, const T& b, T& aa, T& bb)
{
- if(a < b)
+ if (a < b)
{
aa = a;
bb = b;
enum cpp_integer_type
{
- signed_magnitude = 1,
+ signed_magnitude = 1,
unsigned_magnitude = 0,
- signed_packed = 3,
- unsigned_packed = 2
+ signed_packed = 3,
+ unsigned_packed = 2
};
enum cpp_int_check_type
{
- checked = 1,
+ checked = 1,
unchecked = 0
};
-}}
+} // namespace multiprecision
+} // namespace boost
//
// Figure out whether to support user-defined-literals or not:
//
-#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_USER_DEFINED_LITERALS) \
- && !defined(BOOST_NO_CXX11_CONSTEXPR)
-# define BOOST_MP_USER_DEFINED_LITERALS
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_USER_DEFINED_LITERALS) && !defined(BOOST_NO_CXX11_CONSTEXPR)
+#define BOOST_MP_USER_DEFINED_LITERALS
#endif
#endif // BOOST_MP_CPP_INT_CORE_HPP
-