/usr/include/boost/multiprecision/detail
Edit: /usr/include/boost/multiprecision/detail/number_base.hpp (76769B)
///////////////////////////////////////////////////////////////////////////////
// Copyright 2011 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)
#ifndef BOOST_MATH_BIG_NUM_BASE_HPP
#define BOOST_MATH_BIG_NUM_BASE_HPP
#include
#include
#include
#include
#include
#include
#include
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable : 4307)
#endif
#include
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) || defined(BOOST_NO_CXX11_HDR_ARRAY)\
|| defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) || defined(BOOST_NO_CXX11_CONSTEXPR)\
|| defined(BOOST_MP_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) || defined(BOOST_NO_CXX11_REF_QUALIFIERS) || defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)\
|| defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_USER_DEFINED_LITERALS) || defined(BOOST_NO_CXX11_THREAD_LOCAL)\
|| defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_STATIC_ASSERT) || defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)\
|| defined(BOOST_NO_CXX11_NOEXCEPT) || defined(BOOST_NO_CXX11_REF_QUALIFIERS)
//
// The above list includes everything we use, plus a few we're likely to use soon.
// As from March 2020, C++03 support is deprecated, and as from March 2021 will be removed,
// so mark up as such:
//
#if (defined(_MSC_VER) || defined(__GNUC__)) && !defined(BOOST_MP_DISABLE_DEPRECATE_03_WARNING)
#pragma message("CAUTION: One or more C++11 features were found to be unavailable")
#pragma message("CAUTION: Compiling Boost.Multiprecision in non-C++11 or later conformance modes is now deprecated and will be removed from March 2021.")
#pragma message("CAUTION: Define BOOST_MP_DISABLE_DEPRECATE_03_WARNING to suppress this message.")
#endif
#endif
#if defined(NDEBUG) && !defined(_DEBUG)
#define BOOST_MP_FORCEINLINE BOOST_FORCEINLINE
#else
#define BOOST_MP_FORCEINLINE inline
#endif
#if (defined(BOOST_GCC) && (BOOST_GCC <= 40700)) || BOOST_WORKAROUND(__SUNPRO_CC, < 0x5140) || (defined(__clang_major__) && (__clang_major__ == 3) && (__clang_minor__ < 5))
#define BOOST_MP_NOEXCEPT_IF(x)
#else
#define BOOST_MP_NOEXCEPT_IF(x) BOOST_NOEXCEPT_IF(x)
#endif
#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) || BOOST_WORKAROUND(__SUNPRO_CC, < 0x5140)
#define BOOST_MP_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
#endif
//
// Thread local storage:
// Note fails on Mingw, see https://sourceforge.net/p/mingw-w64/bugs/527/
//
#if !defined(BOOST_NO_CXX11_THREAD_LOCAL) && !defined(BOOST_INTEL) && !defined(__MINGW32__)
#define BOOST_MP_THREAD_LOCAL thread_local
#define BOOST_MP_USING_THREAD_LOCAL
#else
#define BOOST_MP_THREAD_LOCAL
#endif
#ifdef __has_include
# if __has_include()
# include
# ifdef __cpp_lib_is_constant_evaluated
# include
# define BOOST_MP_HAS_IS_CONSTANT_EVALUATED
# endif
# endif
#endif
#ifdef __has_builtin
#if __has_builtin(__builtin_is_constant_evaluated) && !defined(BOOST_NO_CXX14_CONSTEXPR) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
#define BOOST_MP_HAS_BUILTIN_IS_CONSTANT_EVALUATED
#endif
#endif
//
// MSVC also supports __builtin_is_constant_evaluated if it's recent enough:
//
#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 192528326)
# define BOOST_MP_HAS_BUILTIN_IS_CONSTANT_EVALUATED
#endif
//
// As does GCC-9:
//
#if defined(BOOST_GCC) && !defined(BOOST_NO_CXX14_CONSTEXPR) && (__GNUC__ >= 9) && !defined(BOOST_MP_HAS_BUILTIN_IS_CONSTANT_EVALUATED)
# define BOOST_MP_HAS_BUILTIN_IS_CONSTANT_EVALUATED
#endif
#if defined(BOOST_MP_HAS_IS_CONSTANT_EVALUATED) && !defined(BOOST_NO_CXX14_CONSTEXPR)
# define BOOST_MP_IS_CONST_EVALUATED(x) std::is_constant_evaluated()
#elif defined(BOOST_MP_HAS_BUILTIN_IS_CONSTANT_EVALUATED)
# define BOOST_MP_IS_CONST_EVALUATED(x) __builtin_is_constant_evaluated()
#elif !defined(BOOST_NO_CXX14_CONSTEXPR) && defined(BOOST_GCC) && (__GNUC__ >= 6)
# define BOOST_MP_IS_CONST_EVALUATED(x) __builtin_constant_p(x)
#else
# define BOOST_MP_NO_CONSTEXPR_DETECTION
#endif
#define BOOST_MP_CXX14_CONSTEXPR BOOST_CXX14_CONSTEXPR
//
// Early compiler versions trip over the constexpr code:
//
#if defined(__clang__) && (__clang_major__ < 5)
#undef BOOST_MP_CXX14_CONSTEXPR
#define BOOST_MP_CXX14_CONSTEXPR
#endif
#if defined(__apple_build_version__) && (__clang_major__ < 9)
#undef BOOST_MP_CXX14_CONSTEXPR
#define BOOST_MP_CXX14_CONSTEXPR
#endif
#if defined(BOOST_GCC) && (__GNUC__ < 6)
#undef BOOST_MP_CXX14_CONSTEXPR
#define BOOST_MP_CXX14_CONSTEXPR
#endif
#if defined(BOOST_INTEL)
#undef BOOST_MP_CXX14_CONSTEXPR
#define BOOST_MP_CXX14_CONSTEXPR
#define BOOST_MP_NO_CONSTEXPR_DETECTION
#endif
#ifdef BOOST_MP_NO_CONSTEXPR_DETECTION
# define BOOST_CXX14_CONSTEXPR_IF_DETECTION
#else
# define BOOST_CXX14_CONSTEXPR_IF_DETECTION constexpr
#endif
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable : 6326)
#endif
namespace boost {
namespace multiprecision {
enum expression_template_option
{
et_off = 0,
et_on = 1
};
template
struct expression_template_default
{
static const expression_template_option value = et_on;
};
template ::value>
class number;
template
struct is_number : public mpl::false_
{};
template
struct is_number > : public mpl::true_
{};
template
struct is_et_number : public mpl::false_
{};
template
struct is_et_number > : public mpl::true_
{};
template
struct is_no_et_number : public mpl::false_
{};
template
struct is_no_et_number > : public mpl::true_
{};
namespace detail {
// Forward-declare an expression wrapper
template
struct expression;
} // namespace detail
template
struct is_number_expression : public mpl::false_
{};
template
struct is_number_expression > : public mpl::true_
{};
template
struct is_compatible_arithmetic_type
: public mpl::bool_<
is_convertible::value && !is_same::value && !is_number_expression::value>
{};
namespace detail {
//
// Workaround for missing abs(boost::long_long_type) and abs(__int128) on some compilers:
//
template
BOOST_CONSTEXPR typename enable_if_c<(is_signed::value || is_floating_point::value), T>::type abs(T t) BOOST_NOEXCEPT
{
// This strange expression avoids a hardware trap in the corner case
// that val is the most negative value permitted in boost::long_long_type.
// See https://svn.boost.org/trac/boost/ticket/9740.
return t < 0 ? T(1u) + T(-(t + 1)) : t;
}
template
BOOST_CONSTEXPR typename enable_if_c<(is_unsigned::value), T>::type abs(T t) BOOST_NOEXCEPT
{
return t;
}
#define BOOST_MP_USING_ABS using boost::multiprecision::detail::abs;
template
BOOST_CONSTEXPR typename enable_if_c<(is_signed::value || is_floating_point::value), typename make_unsigned::type>::type unsigned_abs(T t) BOOST_NOEXCEPT
{
// This strange expression avoids a hardware trap in the corner case
// that val is the most negative value permitted in boost::long_long_type.
// See https://svn.boost.org/trac/boost/ticket/9740.
return t < 0 ? static_cast::type>(1u) + static_cast::type>(-(t + 1)) : static_cast::type>(t);
}
template
BOOST_CONSTEXPR typename enable_if_c<(is_unsigned::value), T>::type unsigned_abs(T t) BOOST_NOEXCEPT
{
return t;
}
//
// Move support:
//
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
#define BOOST_MP_MOVE(x) std::move(x)
#else
#define BOOST_MP_MOVE(x) x
#endif
template
struct bits_of
{
BOOST_STATIC_ASSERT(is_integral::value || is_enum::value || std::numeric_limits::is_specialized);
static const unsigned value =
std::numeric_limits::is_specialized ? std::numeric_limits::digits
: sizeof(T) * CHAR_BIT - (is_signed::value ? 1 : 0);
};
#if defined(_GLIBCXX_USE_FLOAT128) && defined(BOOST_GCC) && !defined(__STRICT_ANSI__)
#define BOOST_MP_BITS_OF_FLOAT128_DEFINED
template <>
struct bits_of<__float128>
{
static const unsigned value = 113;
};
#endif
template
struct has_enough_bits
{
template
struct type : public mpl::bool_::value >= b>
{};
};
template
struct canonical_imp
{
typedef typename remove_cv::type>::type type;
};
template
struct canonical_imp, Backend, Tag>
{
typedef B type;
};
template
struct canonical_imp, Backend, Tag>
{
typedef B type;
};
#ifdef __SUNPRO_CC
template
struct canonical_imp, Backend, mpl::int_<3> >
{
typedef B type;
};
template
struct canonical_imp, Backend, mpl::int_<3> >
{
typedef B type;
};
#endif
template
struct canonical_imp >
{
typedef typename has_enough_bits::value>::template type pred_type;
typedef typename mpl::find_if<
typename Backend::signed_types,
pred_type>::type iter_type;
typedef typename mpl::end::type end_type;
typedef typename mpl::eval_if, mpl::identity, mpl::deref >::type type;
};
template
struct canonical_imp >
{
typedef typename has_enough_bits::value>::template type pred_type;
typedef typename mpl::find_if<
typename Backend::unsigned_types,
pred_type>::type iter_type;
typedef typename mpl::end::type end_type;
typedef typename mpl::eval_if, mpl::identity, mpl::deref >::type type;
};
template
struct canonical_imp >
{
typedef typename has_enough_bits::value>::template type pred_type;
typedef typename mpl::find_if<
typename Backend::float_types,
pred_type>::type iter_type;
typedef typename mpl::end::type end_type;
typedef typename mpl::eval_if, mpl::identity, mpl::deref >::type type;
};
template
struct canonical_imp >
{
typedef const char* type;
};
template
struct canonical
{
typedef typename mpl::if_<
is_signed,
mpl::int_<0>,
typename mpl::if_<
is_unsigned,
mpl::int_<1>,
typename mpl::if_<
is_floating_point,
mpl::int_<2>,
typename mpl::if_<
mpl::or_<
is_convertible,
is_same >,
mpl::int_<3>,
mpl::int_<4> >::type>::type>::type>::type tag_type;
typedef typename canonical_imp::type type;
};
struct terminal
{};
struct negate
{};
struct plus
{};
struct minus
{};
struct multiplies
{};
struct divides
{};
struct modulus
{};
struct shift_left
{};
struct shift_right
{};
struct bitwise_and
{};
struct bitwise_or
{};
struct bitwise_xor
{};
struct bitwise_complement
{};
struct add_immediates
{};
struct subtract_immediates
{};
struct multiply_immediates
{};
struct divide_immediates
{};
struct modulus_immediates
{};
struct bitwise_and_immediates
{};
struct bitwise_or_immediates
{};
struct bitwise_xor_immediates
{};
struct complement_immediates
{};
struct function
{};
struct multiply_add
{};
struct multiply_subtract
{};
template
struct backend_type;
template
struct backend_type >
{
typedef T type;
};
template
struct backend_type >
{
typedef typename backend_type::result_type>::type type;
};
template
struct combine_expression
{
#ifdef BOOST_NO_CXX11_DECLTYPE
typedef typename mpl::if_c<(sizeof(T1() + T2()) == sizeof(T1)), T1, T2>::type type;
#else
typedef decltype(T1() + T2()) type;
#endif
};
template
struct combine_expression, T2>
{
typedef number type;
};
template
struct combine_expression >
{
typedef number type;
};
template
struct combine_expression, number >
{
typedef number type;
};
template
struct combine_expression, number >
{
typedef typename mpl::if_c<
is_convertible, number >::value,
number,
number >::type type;
};
template
struct arg_type
{
typedef expression type;
};
template
struct arg_type >
{
typedef expression type;
};
struct unmentionable
{
unmentionable* proc() { return 0; }
};
typedef unmentionable* (unmentionable::*unmentionable_type)();
template
struct expression_storage_base
{
typedef const T& type;
};
template
struct expression_storage_base
{
typedef T type;
};
template
struct expression_storage : public expression_storage_base::value>
{};
template
struct expression_storage
{
typedef T* type;
};
template
struct expression_storage
{
typedef const T* type;
};
template
struct expression_storage >
{
typedef expression type;
};
template
struct expression
{
typedef mpl::int_<1> arity;
typedef typename arg_type::type left_type;
typedef typename left_type::result_type left_result_type;
typedef typename left_type::result_type result_type;
typedef tag tag_type;
explicit BOOST_MP_CXX14_CONSTEXPR expression(const Arg1& a) : arg(a) {}
BOOST_MP_CXX14_CONSTEXPR expression(const expression& e) : arg(e.arg) {}
#ifndef BOOST_NO_CXX11_STATIC_ASSERT
//
// If we have static_assert we can give a more useful error message
// than if we simply have no operator defined at all:
//
template
BOOST_MP_CXX14_CONSTEXPR expression& operator=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not assign to a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator++()
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not increment a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator++(int)
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not increment a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator--()
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not decrement a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator--(int)
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not decrement a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator+=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator+= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator-=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator-= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator*=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator*= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator/=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator/= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator%=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator%= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator|=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator|= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator&=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator&= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator^=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator^= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator<<=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator<<= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator>>=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator>>= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
#endif
BOOST_MP_CXX14_CONSTEXPR left_type left() const
{
return left_type(arg);
}
BOOST_MP_CXX14_CONSTEXPR const Arg1& left_ref() const BOOST_NOEXCEPT { return arg; }
static const unsigned depth = left_type::depth + 1;
#ifndef BOOST_MP_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
#if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7) && !defined(__clang__)) || (defined(BOOST_INTEL) && (BOOST_INTEL <= 1500))
//
// Horrible workaround for gcc-4.6.x which always prefers the template
// operator bool() rather than the non-template operator when converting to
// an arithmetic type:
//
template , int>::type = 0>
explicit operator T() const
{
result_type r(*this);
return static_cast(r);
}
template ::value || is_void::value || is_number::value, int>::type = 0>
explicit operator T() const
{
return static_cast(static_cast(*this));
}
#else
template ::value || is_constructible::value || !is_constructible::value, int>::type = 0
#endif
>
explicit BOOST_MP_CXX14_CONSTEXPR operator T() const
{
return static_cast(static_cast(*this));
}
BOOST_MP_FORCEINLINE explicit BOOST_MP_CXX14_CONSTEXPR operator bool() const
{
result_type r(*this);
return static_cast(r);
}
#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800)
BOOST_MP_FORCEINLINE explicit operator void() const
{}
#endif
#endif
#else
operator unmentionable_type() const
{
result_type r(*this);
return r ? &unmentionable::proc : 0;
}
#endif
template
BOOST_MP_CXX14_CONSTEXPR T convert_to()
{
result_type r(*this);
return r.template convert_to();
}
private:
typename expression_storage::type arg;
expression& operator=(const expression&);
};
template
struct expression
{
typedef mpl::int_<0> arity;
typedef Arg1 result_type;
typedef terminal tag_type;
explicit BOOST_MP_CXX14_CONSTEXPR expression(const Arg1& a) : arg(a) {}
BOOST_MP_CXX14_CONSTEXPR expression(const expression& e) : arg(e.arg) {}
#ifndef BOOST_NO_CXX11_STATIC_ASSERT
//
// If we have static_assert we can give a more useful error message
// than if we simply have no operator defined at all:
//
template
BOOST_MP_CXX14_CONSTEXPR expression& operator=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not assign to a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator++()
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not increment a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator++(int)
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not increment a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator--()
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not decrement a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator--(int)
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not decrement a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator+=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator+= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator-=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator-= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator*=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator*= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator/=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator/= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator%=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator%= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator|=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator|= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator&=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator&= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator^=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator^= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator<<=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator<<= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator>>=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator>>= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
#endif
BOOST_MP_CXX14_CONSTEXPR const Arg1& value() const BOOST_NOEXCEPT
{
return arg;
}
static const unsigned depth = 0;
#ifndef BOOST_MP_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
#if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7) && !defined(__clang__)) || (defined(BOOST_INTEL) && (BOOST_INTEL <= 1500))
//
// Horrible workaround for gcc-4.6.x which always prefers the template
// operator bool() rather than the non-template operator when converting to
// an arithmetic type:
//
template , int>::type = 0>
explicit operator T() const
{
result_type r(*this);
return static_cast(r);
}
template ::value || is_void::value || is_number::value, int>::type = 0>
explicit operator T() const
{
return static_cast(static_cast(*this));
}
#else
template ::value || is_constructible::value || !is_constructible::value, int>::type = 0
#endif
>
explicit BOOST_MP_CXX14_CONSTEXPR operator T() const
{
return static_cast(static_cast(*this));
}
BOOST_MP_FORCEINLINE explicit BOOST_MP_CXX14_CONSTEXPR operator bool() const
{
result_type r(*this);
return static_cast(r);
}
#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800)
BOOST_MP_FORCEINLINE explicit operator void() const
{}
#endif
#endif
#else
operator unmentionable_type() const
{
return arg ? &unmentionable::proc : 0;
}
#endif
template
BOOST_MP_CXX14_CONSTEXPR T convert_to()
{
result_type r(*this);
return r.template convert_to();
}
private:
typename expression_storage::type arg;
expression& operator=(const expression&);
};
template
struct expression
{
typedef mpl::int_<2> arity;
typedef typename arg_type::type left_type;
typedef typename arg_type::type right_type;
typedef typename left_type::result_type left_result_type;
typedef typename right_type::result_type right_result_type;
typedef typename combine_expression::type result_type;
typedef tag tag_type;
BOOST_MP_CXX14_CONSTEXPR expression(const Arg1& a1, const Arg2& a2) : arg1(a1), arg2(a2) {}
BOOST_MP_CXX14_CONSTEXPR expression(const expression& e) : arg1(e.arg1), arg2(e.arg2) {}
#ifndef BOOST_NO_CXX11_STATIC_ASSERT
//
// If we have static_assert we can give a more useful error message
// than if we simply have no operator defined at all:
//
template
BOOST_MP_CXX14_CONSTEXPR expression& operator=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not assign to a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator++()
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not increment a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator++(int)
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not increment a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator--()
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not decrement a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator--(int)
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not decrement a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator+=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator+= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator-=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator-= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator*=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator*= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator/=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator/= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator%=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator%= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator|=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator|= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator&=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator&= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator^=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator^= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator<<=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator<<= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator>>=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator>>= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
#endif
BOOST_MP_CXX14_CONSTEXPR left_type left() const
{
return left_type(arg1);
}
BOOST_MP_CXX14_CONSTEXPR right_type right() const { return right_type(arg2); }
BOOST_MP_CXX14_CONSTEXPR const Arg1& left_ref() const BOOST_NOEXCEPT { return arg1; }
BOOST_MP_CXX14_CONSTEXPR const Arg2& right_ref() const BOOST_NOEXCEPT { return arg2; }
#ifndef BOOST_MP_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
#if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7) && !defined(__clang__)) || (defined(BOOST_INTEL) && (BOOST_INTEL <= 1500))
//
// Horrible workaround for gcc-4.6.x which always prefers the template
// operator bool() rather than the non-template operator when converting to
// an arithmetic type:
//
template , int>::type = 0>
explicit operator T() const
{
result_type r(*this);
return static_cast(r);
}
template ::value || is_void::value || is_number::value, int>::type = 0>
explicit operator T() const
{
return static_cast(static_cast(*this));
}
#else
template ::value || is_constructible::value || !is_constructible::value, int>::type = 0
#endif
>
explicit BOOST_MP_CXX14_CONSTEXPR operator T() const
{
return static_cast(static_cast(*this));
}
BOOST_MP_FORCEINLINE explicit BOOST_MP_CXX14_CONSTEXPR operator bool() const
{
result_type r(*this);
return static_cast(r);
}
#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800)
BOOST_MP_FORCEINLINE explicit operator void() const
{}
#endif
#endif
#else
operator unmentionable_type() const
{
result_type r(*this);
return r ? &unmentionable::proc : 0;
}
#endif
template
BOOST_MP_CXX14_CONSTEXPR T convert_to()
{
result_type r(*this);
return r.template convert_to();
}
static const BOOST_MP_CXX14_CONSTEXPR unsigned left_depth = left_type::depth + 1;
static const BOOST_MP_CXX14_CONSTEXPR unsigned right_depth = right_type::depth + 1;
static const BOOST_MP_CXX14_CONSTEXPR unsigned depth = left_depth > right_depth ? left_depth : right_depth;
private:
typename expression_storage::type arg1;
typename expression_storage::type arg2;
expression& operator=(const expression&);
};
template
struct expression
{
typedef mpl::int_<3> arity;
typedef typename arg_type::type left_type;
typedef typename arg_type::type middle_type;
typedef typename arg_type::type right_type;
typedef typename left_type::result_type left_result_type;
typedef typename middle_type::result_type middle_result_type;
typedef typename right_type::result_type right_result_type;
typedef typename combine_expression<
left_result_type,
typename combine_expression::type>::type result_type;
typedef tag tag_type;
BOOST_MP_CXX14_CONSTEXPR expression(const Arg1& a1, const Arg2& a2, const Arg3& a3) : arg1(a1), arg2(a2), arg3(a3) {}
BOOST_MP_CXX14_CONSTEXPR expression(const expression& e) : arg1(e.arg1), arg2(e.arg2), arg3(e.arg3) {}
#ifndef BOOST_NO_CXX11_STATIC_ASSERT
//
// If we have static_assert we can give a more useful error message
// than if we simply have no operator defined at all:
//
template
BOOST_MP_CXX14_CONSTEXPR expression& operator=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not assign to a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator++()
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not increment a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator++(int)
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not increment a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator--()
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not decrement a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
BOOST_MP_CXX14_CONSTEXPR expression& operator--(int)
{
// This should always fail:
static_assert(sizeof(*this) == INT_MAX, "You can not decrement a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator+=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator+= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator-=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator-= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator*=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator*= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator/=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator/= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator%=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator%= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator|=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator|= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator&=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator&= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator^=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator^= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator<<=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator<<= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
template
BOOST_MP_CXX14_CONSTEXPR expression& operator>>=(const Other&)
{
// This should always fail:
static_assert(sizeof(Other) == INT_MAX, "You can not use operator>>= on a Boost.Multiprecision expression template: did you inadvertantly store an expression template in a \"auto\" variable? Or pass an expression to a template function with deduced temnplate arguments?");
return *this;
}
#endif
BOOST_MP_CXX14_CONSTEXPR left_type left() const
{
return left_type(arg1);
}
BOOST_MP_CXX14_CONSTEXPR middle_type middle() const { return middle_type(arg2); }
BOOST_MP_CXX14_CONSTEXPR right_type right() const { return right_type(arg3); }
BOOST_MP_CXX14_CONSTEXPR const Arg1& left_ref() const BOOST_NOEXCEPT { return arg1; }
BOOST_MP_CXX14_CONSTEXPR const Arg2& middle_ref() const BOOST_NOEXCEPT { return arg2; }
BOOST_MP_CXX14_CONSTEXPR const Arg3& right_ref() const BOOST_NOEXCEPT { return arg3; }
#ifndef BOOST_MP_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
#if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7) && !defined(__clang__)) || (defined(BOOST_INTEL) && (BOOST_INTEL <= 1500))
//
// Horrible workaround for gcc-4.6.x which always prefers the template
// operator bool() rather than the non-template operator when converting to
// an arithmetic type:
//
template , int>::type = 0>
explicit operator T() const
{
result_type r(*this);
return static_cast(r);
}
template ::value || is_void::value || is_number::value, int>::type = 0>
explicit operator T() const
{
return static_cast(static_cast