123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659 |
- ///////////////////////////////////////////////////////////////////////////////
- // Copyright 2012 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_MP_NO_ET_OPS_HPP
- #define BOOST_MP_NO_ET_OPS_HPP
- #ifdef BOOST_MSVC
- #pragma warning(push)
- #pragma warning(disable : 4714)
- #endif
- namespace boost {
- namespace multiprecision {
- //
- // Operators for non-expression template enabled number.
- // NOTE: this is not a complete header - really just a suffix to default_ops.hpp.
- // NOTE: these operators have to be defined after the methods in default_ops.hpp.
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator-(const number<B, et_off>& v)
- {
- static_assert(is_signed_number<B>::value, "Negating an unsigned type results in ill-defined behavior.");
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(v);
- number<B, et_off> result(v);
- result.backend().negate();
- return result;
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator~(const number<B, et_off>& v)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(v);
- number<B, et_off> result;
- eval_complement(result.backend(), v.backend());
- return result;
- }
- //
- // Addition:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator+(const number<B, et_off>& a, const number<B, et_off>& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- number<B, et_off> result;
- using default_ops::eval_add;
- eval_add(result.backend(), a.backend(), b.backend());
- return result;
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value, number<B, et_off> >::type
- operator+(const number<B, et_off>& a, const V& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a);
- number<B, et_off> result;
- using default_ops::eval_add;
- eval_add(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
- return result;
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator+(const V& a, const number<B, et_off>& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(b);
- number<B, et_off> result;
- using default_ops::eval_add;
- eval_add(result.backend(), b.backend(), number<B, et_off>::canonical_value(a));
- return result;
- }
- //
- // Subtraction:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator-(const number<B, et_off>& a, const number<B, et_off>& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- number<B, et_off> result;
- using default_ops::eval_subtract;
- eval_subtract(result.backend(), a.backend(), b.backend());
- return result;
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value, number<B, et_off> >::type
- operator-(const number<B, et_off>& a, const V& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a);
- number<B, et_off> result;
- using default_ops::eval_subtract;
- eval_subtract(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
- return result;
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator-(const V& a, const number<B, et_off>& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(b);
- number<B, et_off> result;
- using default_ops::eval_subtract;
- eval_subtract(result.backend(), number<B, et_off>::canonical_value(a), b.backend());
- return result;
- }
- //
- // Multiply:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator*(const number<B, et_off>& a, const number<B, et_off>& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- number<B, et_off> result;
- using default_ops::eval_multiply;
- eval_multiply(result.backend(), a.backend(), b.backend());
- return result;
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value, number<B, et_off> >::type
- operator*(const number<B, et_off>& a, const V& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a);
- number<B, et_off> result;
- using default_ops::eval_multiply;
- eval_multiply(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
- return result;
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator*(const V& a, const number<B, et_off>& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(b);
- number<B, et_off> result;
- using default_ops::eval_multiply;
- eval_multiply(result.backend(), b.backend(), number<B, et_off>::canonical_value(a));
- return result;
- }
- //
- // divide:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator/(const number<B, et_off>& a, const number<B, et_off>& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- number<B, et_off> result;
- using default_ops::eval_divide;
- eval_divide(result.backend(), a.backend(), b.backend());
- return result;
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value, number<B, et_off> >::type
- operator/(const number<B, et_off>& a, const V& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a);
- number<B, et_off> result;
- using default_ops::eval_divide;
- eval_divide(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
- return result;
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator/(const V& a, const number<B, et_off>& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(b);
- number<B, et_off> result;
- using default_ops::eval_divide;
- eval_divide(result.backend(), number<B, et_off>::canonical_value(a), b.backend());
- return result;
- }
- //
- // modulus:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator%(const number<B, et_off>& a, const number<B, et_off>& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- number<B, et_off> result;
- using default_ops::eval_modulus;
- eval_modulus(result.backend(), a.backend(), b.backend());
- return result;
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator%(const number<B, et_off>& a, const V& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a);
- number<B, et_off> result;
- using default_ops::eval_modulus;
- eval_modulus(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
- return result;
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer) && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator%(const V& a, const number<B, et_off>& b)
- {
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(b);
- number<B, et_off> result;
- using default_ops::eval_modulus;
- eval_modulus(result.backend(), number<B, et_off>::canonical_value(a), b.backend());
- return result;
- }
- //
- // Bitwise or:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator|(const number<B, et_off>& a, const number<B, et_off>& b)
- {
- number<B, et_off> result;
- using default_ops::eval_bitwise_or;
- eval_bitwise_or(result.backend(), a.backend(), b.backend());
- return result;
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator|(const number<B, et_off>& a, const V& b)
- {
- number<B, et_off> result;
- using default_ops::eval_bitwise_or;
- eval_bitwise_or(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
- return result;
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer) && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator|(const V& a, const number<B, et_off>& b)
- {
- number<B, et_off> result;
- using default_ops::eval_bitwise_or;
- eval_bitwise_or(result.backend(), b.backend(), number<B, et_off>::canonical_value(a));
- return result;
- }
- //
- // Bitwise xor:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator^(const number<B, et_off>& a, const number<B, et_off>& b)
- {
- number<B, et_off> result;
- using default_ops::eval_bitwise_xor;
- eval_bitwise_xor(result.backend(), a.backend(), b.backend());
- return result;
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator^(const number<B, et_off>& a, const V& b)
- {
- number<B, et_off> result;
- using default_ops::eval_bitwise_xor;
- eval_bitwise_xor(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
- return result;
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer) && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator^(const V& a, const number<B, et_off>& b)
- {
- number<B, et_off> result;
- using default_ops::eval_bitwise_xor;
- eval_bitwise_xor(result.backend(), b.backend(), number<B, et_off>::canonical_value(a));
- return result;
- }
- //
- // Bitwise and:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator&(const number<B, et_off>& a, const number<B, et_off>& b)
- {
- number<B, et_off> result;
- using default_ops::eval_bitwise_and;
- eval_bitwise_and(result.backend(), a.backend(), b.backend());
- return result;
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator&(const number<B, et_off>& a, const V& b)
- {
- number<B, et_off> result;
- using default_ops::eval_bitwise_and;
- eval_bitwise_and(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
- return result;
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer) && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator&(const V& a, const number<B, et_off>& b)
- {
- number<B, et_off> result;
- using default_ops::eval_bitwise_and;
- eval_bitwise_and(result.backend(), b.backend(), number<B, et_off>::canonical_value(a));
- return result;
- }
- //
- // shifts:
- //
- template <class B, class I>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_integral<I>::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator<<(const number<B, et_off>& a, const I& b)
- {
- number<B, et_off> result(a);
- using default_ops::eval_left_shift;
- detail::check_shift_range(b, std::integral_constant<bool, (sizeof(I) > sizeof(std::size_t))>(), std::integral_constant<bool, boost::multiprecision::detail::is_signed<I>::value>());
- eval_left_shift(result.backend(), b);
- return result;
- }
- template <class B, class I>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_integral<I>::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator>>(const number<B, et_off>& a, const I& b)
- {
- number<B, et_off> result(a);
- using default_ops::eval_right_shift;
- detail::check_shift_range(b, std::integral_constant<bool, (sizeof(I) > sizeof(std::size_t))>(), std::integral_constant<bool, boost::multiprecision::detail::is_signed<I>::value>());
- eval_right_shift(result.backend(), b);
- return result;
- }
- //
- // If we have rvalue references go all over again with rvalue ref overloads and move semantics.
- // Note that while it would be tempting to implement these so they return an rvalue reference
- // (and indeed this would be optimally efficient), this is unsafe due to users propensity to
- // write:
- //
- // const T& t = a * b;
- //
- // which would lead to a dangling reference if we didn't return by value. Of course move
- // semantics help a great deal in return by value, so performance is still pretty good...
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator-(number<B, et_off>&& v)
- {
- static_assert(is_signed_number<B>::value, "Negating an unsigned type results in ill-defined behavior.");
- v.backend().negate();
- return static_cast<number<B, et_off>&&>(v);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator~(number<B, et_off>&& v)
- {
- eval_complement(v.backend(), v.backend());
- return static_cast<number<B, et_off>&&>(v);
- }
- //
- // Addition:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator+(number<B, et_off>&& a, const number<B, et_off>& b)
- {
- using default_ops::eval_add;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_add(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator+(const number<B, et_off>& a, number<B, et_off>&& b)
- {
- using default_ops::eval_add;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_add(b.backend(), a.backend());
- return static_cast<number<B, et_off>&&>(b);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator+(number<B, et_off>&& a, number<B, et_off>&& b)
- {
- using default_ops::eval_add;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_add(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value, number<B, et_off> >::type
- operator+(number<B, et_off>&& a, const V& b)
- {
- using default_ops::eval_add;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_add(a.backend(), number<B, et_off>::canonical_value(b));
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator+(const V& a, number<B, et_off>&& b)
- {
- using default_ops::eval_add;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_add(b.backend(), number<B, et_off>::canonical_value(a));
- return static_cast<number<B, et_off>&&>(b);
- }
- //
- // Subtraction:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator-(number<B, et_off>&& a, const number<B, et_off>& b)
- {
- using default_ops::eval_subtract;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_subtract(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_signed_number<B>::value, number<B, et_off> >::type operator-(const number<B, et_off>& a, number<B, et_off>&& b)
- {
- using default_ops::eval_subtract;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_subtract(b.backend(), a.backend());
- b.backend().negate();
- return static_cast<number<B, et_off>&&>(b);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator-(number<B, et_off>&& a, number<B, et_off>&& b)
- {
- using default_ops::eval_subtract;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_subtract(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value, number<B, et_off> >::type
- operator-(number<B, et_off>&& a, const V& b)
- {
- using default_ops::eval_subtract;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_subtract(a.backend(), number<B, et_off>::canonical_value(b));
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<(is_compatible_arithmetic_type<V, number<B, et_off> >::value && is_signed_number<B>::value) && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator-(const V& a, number<B, et_off>&& b)
- {
- using default_ops::eval_subtract;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_subtract(b.backend(), number<B, et_off>::canonical_value(a));
- b.backend().negate();
- return static_cast<number<B, et_off>&&>(b);
- }
- //
- // Multiply:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator*(number<B, et_off>&& a, const number<B, et_off>& b)
- {
- using default_ops::eval_multiply;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_multiply(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator*(const number<B, et_off>& a, number<B, et_off>&& b)
- {
- using default_ops::eval_multiply;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_multiply(b.backend(), a.backend());
- return static_cast<number<B, et_off>&&>(b);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator*(number<B, et_off>&& a, number<B, et_off>&& b)
- {
- using default_ops::eval_multiply;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_multiply(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value, number<B, et_off> >::type
- operator*(number<B, et_off>&& a, const V& b)
- {
- using default_ops::eval_multiply;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_multiply(a.backend(), number<B, et_off>::canonical_value(b));
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator*(const V& a, number<B, et_off>&& b)
- {
- using default_ops::eval_multiply;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_multiply(b.backend(), number<B, et_off>::canonical_value(a));
- return static_cast<number<B, et_off>&&>(b);
- }
- //
- // divide:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR number<B, et_off> operator/(number<B, et_off>&& a, const number<B, et_off>& b)
- {
- using default_ops::eval_divide;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_divide(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value, number<B, et_off> >::type
- operator/(number<B, et_off>&& a, const V& b)
- {
- using default_ops::eval_divide;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_divide(a.backend(), number<B, et_off>::canonical_value(b));
- return static_cast<number<B, et_off>&&>(a);
- }
- //
- // modulus:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator%(number<B, et_off>&& a, const number<B, et_off>& b)
- {
- using default_ops::eval_modulus;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_modulus(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator%(number<B, et_off>&& a, const V& b)
- {
- using default_ops::eval_modulus;
- detail::scoped_default_precision<multiprecision::number<B, et_off> > precision_guard(a, b);
- eval_modulus(a.backend(), number<B, et_off>::canonical_value(b));
- return static_cast<number<B, et_off>&&>(a);
- }
- //
- // Bitwise or:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator|(number<B, et_off>&& a, const number<B, et_off>& b)
- {
- using default_ops::eval_bitwise_or;
- eval_bitwise_or(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator|(const number<B, et_off>& a, number<B, et_off>&& b)
- {
- using default_ops::eval_bitwise_or;
- eval_bitwise_or(b.backend(), a.backend());
- return static_cast<number<B, et_off>&&>(b);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator|(number<B, et_off>&& a, number<B, et_off>&& b)
- {
- using default_ops::eval_bitwise_or;
- eval_bitwise_or(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator|(number<B, et_off>&& a, const V& b)
- {
- using default_ops::eval_bitwise_or;
- eval_bitwise_or(a.backend(), number<B, et_off>::canonical_value(b));
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer) && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator|(const V& a, number<B, et_off>&& b)
- {
- using default_ops::eval_bitwise_or;
- eval_bitwise_or(b.backend(), number<B, et_off>::canonical_value(a));
- return static_cast<number<B, et_off>&&>(b);
- }
- //
- // Bitwise xor:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator^(number<B, et_off>&& a, const number<B, et_off>& b)
- {
- using default_ops::eval_bitwise_xor;
- eval_bitwise_xor(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator^(const number<B, et_off>& a, number<B, et_off>&& b)
- {
- using default_ops::eval_bitwise_xor;
- eval_bitwise_xor(b.backend(), a.backend());
- return static_cast<number<B, et_off>&&>(b);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator^(number<B, et_off>&& a, number<B, et_off>&& b)
- {
- using default_ops::eval_bitwise_xor;
- eval_bitwise_xor(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator^(number<B, et_off>&& a, const V& b)
- {
- using default_ops::eval_bitwise_xor;
- eval_bitwise_xor(a.backend(), number<B, et_off>::canonical_value(b));
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer) && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator^(const V& a, number<B, et_off>&& b)
- {
- using default_ops::eval_bitwise_xor;
- eval_bitwise_xor(b.backend(), number<B, et_off>::canonical_value(a));
- return static_cast<number<B, et_off>&&>(b);
- }
- //
- // Bitwise and:
- //
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator&(number<B, et_off>&& a, const number<B, et_off>& b)
- {
- using default_ops::eval_bitwise_and;
- eval_bitwise_and(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator&(const number<B, et_off>& a, number<B, et_off>&& b)
- {
- using default_ops::eval_bitwise_and;
- eval_bitwise_and(b.backend(), a.backend());
- return static_cast<number<B, et_off>&&>(b);
- }
- template <class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator&(number<B, et_off>&& a, number<B, et_off>&& b)
- {
- using default_ops::eval_bitwise_and;
- eval_bitwise_and(a.backend(), b.backend());
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B, class V>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator&(number<B, et_off>&& a, const V& b)
- {
- using default_ops::eval_bitwise_and;
- eval_bitwise_and(a.backend(), number<B, et_off>::canonical_value(b));
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class V, class B>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer) && !is_equivalent_number_type<V, B>::value, number<B, et_off> >::type
- operator&(const V& a, number<B, et_off>&& b)
- {
- using default_ops::eval_bitwise_and;
- eval_bitwise_and(b.backend(), number<B, et_off>::canonical_value(a));
- return static_cast<number<B, et_off>&&>(b);
- }
- //
- // shifts:
- //
- template <class B, class I>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_integral<I>::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator<<(number<B, et_off>&& a, const I& b)
- {
- using default_ops::eval_left_shift;
- eval_left_shift(a.backend(), b);
- return static_cast<number<B, et_off>&&>(a);
- }
- template <class B, class I>
- BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_integral<I>::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
- operator>>(number<B, et_off>&& a, const I& b)
- {
- using default_ops::eval_right_shift;
- eval_right_shift(a.backend(), b);
- return static_cast<number<B, et_off>&&>(a);
- }
- }
- } // namespace boost::multiprecision
- #ifdef BOOST_MSVC
- #pragma warning(pop)
- #endif
- #endif // BOOST_MP_NO_ET_OPS_HPP
|