diff --git a/include/boost/decimal/decimal128.hpp b/include/boost/decimal/decimal128.hpp index c0d539774..d681c824d 100644 --- a/include/boost/decimal/decimal128.hpp +++ b/include/boost/decimal/decimal128.hpp @@ -164,31 +164,31 @@ class decimal128 final // Attempts conversion to integral type: // If this is nan sets errno to EINVAL and returns 0 // If this is not representable sets errno to ERANGE and returns 0 - template + template friend constexpr auto to_integral_128(Decimal val) noexcept -> TargetType; - template + template friend BOOST_DECIMAL_CXX20_CONSTEXPR auto to_float(Decimal val) noexcept -> TargetType; - template + template friend constexpr auto to_decimal(Decimal val) noexcept -> TargetType; // Equality template between any integer type and decimal128 - template + template friend constexpr auto mixed_equality_impl(Decimal lhs, Integer rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_integral_v), bool>; - template + template friend constexpr auto mixed_decimal_equality_impl(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool>; // Template to compare operator< for any integer type and decimal128 - template + template friend constexpr auto less_impl(Decimal lhs, Integer rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_integral_v), bool>; - template + template friend constexpr auto mixed_decimal_less_impl(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool>; @@ -214,10 +214,10 @@ class decimal128 final friend constexpr auto d128_mod_impl(decimal128 lhs, decimal128 rhs, const decimal128& q, decimal128& r) noexcept -> void; - template + template friend constexpr auto ilogb(T d) noexcept -> std::enable_if_t, int>; - template + template friend constexpr auto logb(T num) noexcept -> std::enable_if_t, T>; public: @@ -229,10 +229,10 @@ class decimal128 final template , bool> = true> explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal128(Float val) noexcept; - template , bool> = true> + template , bool> = true> constexpr decimal128(Decimal val) noexcept; - template , bool> = true> + template , bool> = true> explicit constexpr decimal128(Integer val) noexcept; // 3.2.5 initialization from coefficient and exponent: @@ -278,7 +278,7 @@ class decimal128 final explicit constexpr operator std::bfloat16_t() const noexcept; #endif - template , bool> = true> + template , bool> = true> explicit constexpr operator Decimal() const noexcept; // cmath functions that are easier as friends @@ -295,41 +295,41 @@ class decimal128 final // 3.2.8 Binary arithmetic operators friend constexpr auto operator+(decimal128 lhs, decimal128 rhs) noexcept -> decimal128; - template + template friend constexpr auto operator+(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128>; - template + template friend constexpr auto operator+(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128>; friend constexpr auto operator-(decimal128 lhs, decimal128 rhs) noexcept -> decimal128; - template + template friend constexpr auto operator-(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128>; - template + template friend constexpr auto operator-(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128>; friend constexpr auto operator*(decimal128 lhs, decimal128 rhs) noexcept -> decimal128; - template + template friend constexpr auto operator*(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128>; - template + template friend constexpr auto operator*(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128>; friend constexpr auto operator/(decimal128 lhs, decimal128 rhs) noexcept -> decimal128; - template + template friend constexpr auto operator/(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128>; - template + template friend constexpr auto operator/(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128>; @@ -344,41 +344,41 @@ class decimal128 final // 3.2.4.6 Compound Assignment constexpr auto operator+=(decimal128 rhs) noexcept -> decimal128&; - template + template constexpr auto operator+=(Integer rhs) noexcept -> std::enable_if_t, decimal128&>; - template + template constexpr auto operator+=(Decimal rhs) noexcept -> std::enable_if_t, decimal128&>; constexpr auto operator-=(decimal128 rhs) noexcept -> decimal128&; - template + template constexpr auto operator-=(Integer rhs) noexcept -> std::enable_if_t, decimal128&>; - template + template constexpr auto operator-=(Decimal rhs) noexcept -> std::enable_if_t, decimal128&>; constexpr auto operator*=(decimal128 rhs) noexcept -> decimal128&; - template + template constexpr auto operator*=(Integer rhs) noexcept -> std::enable_if_t, decimal128&>; - template + template constexpr auto operator*=(Decimal rhs) noexcept -> std::enable_if_t, decimal128&>; constexpr auto operator/=(decimal128 rhs) noexcept -> decimal128&; - template + template constexpr auto operator/=(Integer rhs) noexcept -> std::enable_if_t, decimal128&>; - template + template constexpr auto operator/=(Decimal rhs) noexcept -> std::enable_if_t, decimal128&>; @@ -386,66 +386,66 @@ class decimal128 final // Equality friend constexpr auto operator==(decimal128 lhs, decimal128 rhs) noexcept -> bool; - template + template friend constexpr auto operator==(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator==(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool>; // Inequality friend constexpr auto operator!=(decimal128 lhs, decimal128 rhs) noexcept -> bool; - template + template friend constexpr auto operator!=(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator!=(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool>; // Less friend constexpr auto operator<(decimal128 lhs, decimal128 rhs) noexcept -> bool; - template + template friend constexpr auto operator<(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator<(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool>; // Less equal friend constexpr auto operator<=(decimal128 lhs, decimal128 rhs) noexcept -> bool; - template + template friend constexpr auto operator<=(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator<=(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool>; // Greater friend constexpr auto operator>(decimal128 lhs, decimal128 rhs) noexcept -> bool; - template + template friend constexpr auto operator>(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator>(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool>; // Greater equal friend constexpr auto operator>=(decimal128 lhs, decimal128 rhs) noexcept -> bool; - template + template friend constexpr auto operator>=(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator>=(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool>; @@ -453,21 +453,21 @@ class decimal128 final #ifdef BOOST_DECIMAL_HAS_SPACESHIP_OPERATOR friend constexpr auto operator<=>(decimal128 lhs, decimal128 rhs) noexcept -> std::partial_ordering; - template + template friend constexpr auto operator<=>(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, std::partial_ordering>; - template + template friend constexpr auto operator<=>(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, std::partial_ordering>; #endif #if !defined(BOOST_DECIMAL_DISABLE_IOSTREAM) // 3.2.10 Formatted input: - template + template friend auto operator>>(std::basic_istream& is, DecimalType& d) -> std::enable_if_t, std::basic_istream&>; // 3.2.11 Formatted output: - template + template friend auto operator<<(std::basic_ostream& os, const DecimalType& d) -> std::enable_if_t, std::basic_ostream&>; @@ -486,58 +486,58 @@ class decimal128 final // Bit-wise operators friend constexpr auto operator&(decimal128 lhs, decimal128 rhs) noexcept -> decimal128; - template + template friend constexpr auto operator&(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128>; - template + template friend constexpr auto operator&(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128>; friend constexpr auto operator|(decimal128 lhs, decimal128 rhs) noexcept -> decimal128; - template + template friend constexpr auto operator|(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128>; - template + template friend constexpr auto operator|(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128>; friend constexpr auto operator^(decimal128 lhs, decimal128 rhs) noexcept -> decimal128; - template + template friend constexpr auto operator^(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128>; - template + template friend constexpr auto operator^(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128>; friend constexpr auto operator<<(decimal128 lhs, decimal128 rhs) noexcept -> decimal128; - template + template friend constexpr auto operator<<(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128>; - template + template friend constexpr auto operator<<(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128>; friend constexpr auto operator>>(decimal128 lhs, decimal128 rhs) noexcept -> decimal128; - template + template friend constexpr auto operator>>(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128>; - template + template friend constexpr auto operator>>(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128>; friend constexpr auto operator~(decimal128 rhs) noexcept -> decimal128; // functions that need to be friends - template + template friend constexpr auto frexp10(T num, int* expptr) noexcept -> std::enable_if_t, std::conditional_t::value, std::uint32_t, @@ -853,14 +853,14 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal128::decimal128(Float val) noexcept } } -template , bool>> +template , bool>> constexpr decimal128::decimal128(Integer val) noexcept // NOLINT : Incorrect parameter is never used { using ConversionType = std::conditional_t::value, std::int32_t, Integer>; *this = decimal128{static_cast(val), 0}; } -template , bool>> +template , bool>> constexpr decimal128::decimal128(Decimal val) noexcept { *this = to_decimal(val); @@ -982,7 +982,7 @@ constexpr decimal128::operator std::bfloat16_t() const noexcept } #endif -template , bool>> +template , bool>> constexpr decimal128::operator Decimal() const noexcept { return to_decimal(*this); @@ -1046,14 +1046,14 @@ constexpr auto operator==(decimal128 lhs, decimal128 rhs) noexcept -> bool rhs.full_significand(), rhs.biased_exponent(), rhs.isneg()); } -template +template constexpr auto operator==(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { return mixed_equality_impl(lhs, rhs); } -template +template constexpr auto operator==(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool> { @@ -1065,14 +1065,14 @@ constexpr auto operator!=(decimal128 lhs, decimal128 rhs) noexcept -> bool return !(lhs == rhs); } -template +template constexpr auto operator!=(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { return !(lhs == rhs); } -template +template constexpr auto operator!=(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool> { @@ -1106,14 +1106,14 @@ constexpr auto operator<(decimal128 lhs, decimal128 rhs) noexcept -> bool rhs.full_significand(), rhs.biased_exponent(), rhs.isneg()); } -template +template constexpr auto operator<(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { return less_impl(lhs, rhs); } -template +template constexpr auto operator<(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool> { @@ -1135,7 +1135,7 @@ constexpr auto operator<=(decimal128 lhs, decimal128 rhs) noexcept -> bool return !(rhs < lhs); } -template +template constexpr auto operator<=(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { @@ -1147,7 +1147,7 @@ constexpr auto operator<=(decimal128 lhs, Integer rhs) noexcept return !(rhs < lhs); } -template +template constexpr auto operator<=(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool> { @@ -1164,14 +1164,14 @@ constexpr auto operator>(decimal128 lhs, decimal128 rhs) noexcept -> bool return rhs < lhs; } -template +template constexpr auto operator>(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { return rhs < lhs; } -template +template constexpr auto operator>(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool> { @@ -1188,7 +1188,7 @@ constexpr auto operator>=(decimal128 lhs, decimal128 rhs) noexcept -> bool return !(lhs < rhs); } -template +template constexpr auto operator>=(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { @@ -1200,7 +1200,7 @@ constexpr auto operator>=(decimal128 lhs, Integer rhs) noexcept return !(lhs < rhs); } -template +template constexpr auto operator>=(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, bool> { @@ -1232,7 +1232,7 @@ constexpr auto operator<=>(decimal128 lhs, decimal128 rhs) noexcept -> std::part return std::partial_ordering::unordered; } -template +template constexpr auto operator<=>(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, std::partial_ordering> { if (lhs < rhs) @@ -1251,7 +1251,7 @@ constexpr auto operator<=>(decimal128 lhs, Integer rhs) noexcept -> std::enable_ return std::partial_ordering::unordered; } -template +template constexpr auto operator<=>(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, std::partial_ordering> { if (lhs < rhs) @@ -1650,7 +1650,7 @@ constexpr auto operator+(decimal128 lhs, decimal128 rhs) noexcept -> decimal128 return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator+(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128> { @@ -1708,7 +1708,7 @@ constexpr auto operator+(decimal128 lhs, Integer rhs) noexcept return decimal128(result.sig, result.exp, result.sign); } -template +template constexpr auto operator+(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128> { @@ -1748,7 +1748,7 @@ constexpr auto operator-(decimal128 lhs, decimal128 rhs) noexcept -> decimal128 return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator-(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128> { @@ -1782,7 +1782,7 @@ constexpr auto operator-(decimal128 lhs, Integer rhs) noexcept return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator-(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128> { @@ -1850,7 +1850,7 @@ constexpr auto operator*(decimal128 lhs, decimal128 rhs) noexcept -> decimal128 return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator*(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128> { @@ -1884,7 +1884,7 @@ constexpr auto operator*(decimal128 lhs, Integer rhs) noexcept return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator*(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128> { @@ -1900,7 +1900,7 @@ constexpr auto operator/(decimal128 lhs, decimal128 rhs) noexcept -> decimal128 return q; } -template +template constexpr auto operator/(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128> { @@ -1946,7 +1946,7 @@ constexpr auto operator/(decimal128 lhs, Integer rhs) noexcept return decimal128(q_components.sig, q_components.exp, q_components.sign); } -template +template constexpr auto operator/(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128> { // Check pre-conditions @@ -2026,7 +2026,7 @@ constexpr auto decimal128::operator+=(decimal128 rhs) noexcept -> decimal128& return *this; } -template +template constexpr auto decimal128::operator+=(Integer rhs) noexcept -> std::enable_if_t, decimal128&> { @@ -2034,7 +2034,7 @@ constexpr auto decimal128::operator+=(Integer rhs) noexcept return *this; } -template +template constexpr auto decimal128::operator+=(Decimal rhs) noexcept -> std::enable_if_t, decimal128&> { @@ -2048,7 +2048,7 @@ constexpr auto decimal128::operator-=(decimal128 rhs) noexcept -> decimal128& return *this; } -template +template constexpr auto decimal128::operator-=(Integer rhs) noexcept -> std::enable_if_t, decimal128&> { @@ -2056,7 +2056,7 @@ constexpr auto decimal128::operator-=(Integer rhs) noexcept return *this; } -template +template constexpr auto decimal128::operator-=(Decimal rhs) noexcept -> std::enable_if_t, decimal128&> { @@ -2070,7 +2070,7 @@ constexpr auto decimal128::operator*=(decimal128 rhs) noexcept -> decimal128& return *this; } -template +template constexpr auto decimal128::operator*=(Integer rhs) noexcept -> std::enable_if_t, decimal128&> { @@ -2078,7 +2078,7 @@ constexpr auto decimal128::operator*=(Integer rhs) noexcept return *this; } -template +template constexpr auto decimal128::operator*=(Decimal rhs) noexcept -> std::enable_if_t, decimal128&> { @@ -2092,7 +2092,7 @@ constexpr auto decimal128::operator/=(decimal128 rhs) noexcept -> decimal128& return *this; } -template +template constexpr auto decimal128::operator/=(Integer rhs) noexcept -> std::enable_if_t, decimal128&> { @@ -2100,7 +2100,7 @@ constexpr auto decimal128::operator/=(Integer rhs) noexcept return *this; } -template +template constexpr auto decimal128::operator/=(Decimal rhs) noexcept -> std::enable_if_t, decimal128&> { @@ -2184,14 +2184,14 @@ constexpr auto operator&(decimal128 lhs, decimal128 rhs) noexcept -> decimal128 return from_bits(lhs.bits_ & rhs.bits_); } -template +template constexpr auto operator&(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128> { return from_bits(lhs.bits_ & static_cast(rhs)); } -template +template constexpr auto operator&(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128> { @@ -2203,14 +2203,14 @@ constexpr auto operator|(decimal128 lhs, decimal128 rhs) noexcept -> decimal128 return from_bits(lhs.bits_ | rhs.bits_); } -template +template constexpr auto operator|(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128> { return from_bits(lhs.bits_ | static_cast(rhs)); } -template +template constexpr auto operator|(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128> { @@ -2222,14 +2222,14 @@ constexpr auto operator^(decimal128 lhs, decimal128 rhs) noexcept -> decimal128 return from_bits(lhs.bits_ ^ rhs.bits_); } -template +template constexpr auto operator^(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128> { return from_bits(lhs.bits_ ^ static_cast(rhs)); } -template +template constexpr auto operator^(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128> { @@ -2241,14 +2241,14 @@ constexpr auto operator<<(decimal128 lhs, decimal128 rhs) noexcept -> decimal128 return from_bits(lhs.bits_ << static_cast(rhs.bits_)); } -template +template constexpr auto operator<<(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128> { return from_bits(lhs.bits_ << static_cast(rhs)); } -template +template constexpr auto operator<<(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128> { @@ -2260,14 +2260,14 @@ constexpr auto operator>>(decimal128 lhs, decimal128 rhs) noexcept -> decimal128 return from_bits(lhs.bits_ >> static_cast(rhs.bits_)); } -template +template constexpr auto operator>>(decimal128 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal128> { return from_bits(lhs.bits_ >> static_cast(rhs)); } -template +template constexpr auto operator>>(Integer lhs, decimal128 rhs) noexcept -> std::enable_if_t, decimal128> { diff --git a/include/boost/decimal/decimal32.hpp b/include/boost/decimal/decimal32.hpp index d821985c3..db3a841a7 100644 --- a/include/boost/decimal/decimal32.hpp +++ b/include/boost/decimal/decimal32.hpp @@ -148,13 +148,13 @@ class decimal32 final // NOLINT(cppcoreguidelines-special-member-functions,hicpp // Attempts conversion to integral type: // If this is nan sets errno to EINVAL and returns 0 // If this is not representable sets errno to ERANGE and returns 0 - template + template friend constexpr auto to_integral(Decimal val) noexcept -> TargetType; - template + template friend BOOST_DECIMAL_CXX20_CONSTEXPR auto to_float(Decimal val) noexcept -> TargetType; - template + template friend constexpr auto to_decimal(Decimal val) noexcept -> TargetType; friend constexpr auto generic_div_impl(detail::decimal32_components lhs, detail::decimal32_components rhs, @@ -162,10 +162,10 @@ class decimal32 final // NOLINT(cppcoreguidelines-special-member-functions,hicpp friend constexpr auto div_impl(decimal32 lhs, decimal32 rhs, decimal32& q, decimal32& r) noexcept -> void; friend constexpr auto mod_impl(decimal32 lhs, decimal32 rhs, const decimal32& q, decimal32& r) noexcept -> void; - template + template friend constexpr auto ilogb(T d) noexcept -> std::enable_if_t, int>; - template + template friend constexpr auto logb(T num) noexcept -> std::enable_if_t, T>; // Debug bit pattern @@ -174,21 +174,21 @@ class decimal32 final // NOLINT(cppcoreguidelines-special-member-functions,hicpp friend auto debug_pattern(decimal32 rhs) noexcept -> void; // Equality template between any integer type and decimal32 - template + template friend constexpr auto mixed_equality_impl(Decimal lhs, Integer rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_integral_v), bool>; - template + template friend constexpr auto mixed_decimal_equality_impl(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool>; // Template to compare operator< for any integer type and decimal32 - template + template friend constexpr auto less_impl(Decimal lhs, Integer rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_integral_v), bool>; - template + template friend constexpr auto mixed_decimal_less_impl(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool>; @@ -214,11 +214,11 @@ class decimal32 final // NOLINT(cppcoreguidelines-special-member-functions,hicpp template , bool> = true> explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal32(Float val) noexcept; - template , bool> = true> + template , bool> = true> explicit constexpr decimal32(Decimal val) noexcept; // 3.2.2.3 Conversion from integral type - template , bool> = true> + template , bool> = true> explicit constexpr decimal32(Integer val) noexcept; // 3.2.2.4 Conversion to integral type @@ -239,7 +239,7 @@ class decimal32 final // NOLINT(cppcoreguidelines-special-member-functions,hicpp explicit constexpr operator detail::uint128_t() const noexcept; #endif - template , bool> = true> + template , bool> = true> explicit constexpr operator Decimal() const noexcept; // 3.2.5 initialization from coefficient and exponent: @@ -286,41 +286,41 @@ class decimal32 final // NOLINT(cppcoreguidelines-special-member-functions,hicpp // 3.2.8 binary arithmetic operators: friend constexpr auto operator+(decimal32 lhs, decimal32 rhs) noexcept -> decimal32; - template + template friend constexpr auto operator+(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32>; - template + template friend constexpr auto operator+(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32>; friend constexpr auto operator-(decimal32 lhs, decimal32 rhs) noexcept -> decimal32; - template + template friend constexpr auto operator-(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32>; - template + template friend constexpr auto operator-(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32>; friend constexpr auto operator*(decimal32 lhs, decimal32 rhs) noexcept -> decimal32; - template + template friend constexpr auto operator*(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32>; - template + template friend constexpr auto operator*(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32>; friend constexpr auto operator/(decimal32 lhs, decimal32 rhs) noexcept -> decimal32; - template + template friend constexpr auto operator/(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32>; - template + template friend constexpr auto operator/(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32>; @@ -335,41 +335,41 @@ class decimal32 final // NOLINT(cppcoreguidelines-special-member-functions,hicpp // 3.2.2.6 Compound assignment constexpr auto operator+=(decimal32 rhs) noexcept -> decimal32&; - template + template constexpr auto operator+=(Integer rhs) noexcept -> std::enable_if_t, decimal32&>; - template + template constexpr auto operator+=(Decimal rhs) noexcept -> std::enable_if_t, decimal32&>; constexpr auto operator-=(decimal32 rhs) noexcept -> decimal32&; - template + template constexpr auto operator-=(Integer rhs) noexcept -> std::enable_if_t, decimal32&>; - template + template constexpr auto operator-=(Decimal rhs) noexcept -> std::enable_if_t, decimal32&>; constexpr auto operator*=(decimal32 rhs) noexcept -> decimal32&; - template + template constexpr auto operator*=(Integer rhs) noexcept -> std::enable_if_t, decimal32&>; - template + template constexpr auto operator*=(Decimal rhs) noexcept -> std::enable_if_t, decimal32&>; constexpr auto operator/=(decimal32 rhs) noexcept -> decimal32&; - template + template constexpr auto operator/=(Integer rhs) noexcept -> std::enable_if_t, decimal32&>; - template + template constexpr auto operator/=(Decimal rhs) noexcept -> std::enable_if_t, decimal32&>; @@ -379,87 +379,87 @@ class decimal32 final // NOLINT(cppcoreguidelines-special-member-functions,hicpp // Equality friend constexpr auto operator==(decimal32 lhs, decimal32 rhs) noexcept -> bool; - template + template friend constexpr auto operator==(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator==(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool>; // Inequality friend constexpr auto operator!=(decimal32 lhs, decimal32 rhs) noexcept -> bool; - template + template friend constexpr auto operator!=(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator!=(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool>; // Less friend constexpr auto operator<(decimal32 lhs, decimal32 rhs) noexcept -> bool; - template + template friend constexpr auto operator<(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator<(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool>; // Less equal friend constexpr auto operator<=(decimal32 lhs, decimal32 rhs) noexcept -> bool; - template + template friend constexpr auto operator<=(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator<=(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool>; // Greater friend constexpr auto operator>(decimal32 lhs, decimal32 rhs) noexcept -> bool; - template + template friend constexpr auto operator>(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator>(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool>; // Greater equal friend constexpr auto operator>=(decimal32 lhs, decimal32 rhs) noexcept -> bool; - template + template friend constexpr auto operator>=(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator>=(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool>; #ifdef BOOST_DECIMAL_HAS_SPACESHIP_OPERATOR friend constexpr auto operator<=>(decimal32 lhs, decimal32 rhs) noexcept -> std::partial_ordering; - template + template friend constexpr auto operator<=>(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, std::partial_ordering>; - template + template friend constexpr auto operator<=>(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, std::partial_ordering>; #endif #if !defined(BOOST_DECIMAL_DISABLE_IOSTREAM) // 3.2.10 Formatted input: - template + template friend auto operator>>(std::basic_istream& is, DecimalType& d) -> std::enable_if_t, std::basic_istream&>; // 3.2.11 Formatted output: - template + template friend auto operator<<(std::basic_ostream& os, const DecimalType& d) -> std::enable_if_t, std::basic_ostream&>; #endif @@ -467,51 +467,51 @@ class decimal32 final // NOLINT(cppcoreguidelines-special-member-functions,hicpp // Bitwise operators friend constexpr auto operator&(decimal32 lhs, decimal32 rhs) noexcept -> decimal32; - template + template friend constexpr auto operator&(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32>; - template + template friend constexpr auto operator&(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32>; friend constexpr auto operator|(decimal32 lhs, decimal32 rhs) noexcept -> decimal32; - template + template friend constexpr auto operator|(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32>; - template + template friend constexpr auto operator|(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32>; friend constexpr auto operator^(decimal32 lhs, decimal32 rhs) noexcept -> decimal32; - template + template friend constexpr auto operator^(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32>; - template + template friend constexpr auto operator^(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32>; friend constexpr auto operator<<(decimal32 lhs, decimal32 rhs) noexcept -> decimal32; - template + template friend constexpr auto operator<<(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32>; - template + template friend constexpr auto operator<<(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32>; friend constexpr auto operator>>(decimal32 lhs, decimal32 rhs) noexcept -> decimal32; - template + template friend constexpr auto operator>>(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32>; - template + template friend constexpr auto operator>>(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32>; @@ -532,7 +532,7 @@ class decimal32 final // NOLINT(cppcoreguidelines-special-member-functions,hicpp friend constexpr auto fmad32(decimal32 x, decimal32 y, decimal32 z) noexcept -> decimal32; // Related to - template + template friend constexpr auto frexp10(T num, int* expptr) noexcept -> std::enable_if_t, std::conditional_t::value, std::uint32_t, @@ -988,7 +988,7 @@ constexpr auto operator+(decimal32 lhs, decimal32 rhs) noexcept -> decimal32 return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator+(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32> { if (isnan(lhs) || isinf(lhs)) @@ -1038,7 +1038,7 @@ constexpr auto operator+(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_ return decimal32(result.sig, result.exp, result.sign); } -template +template constexpr auto operator+(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32> { return rhs + lhs; @@ -1062,7 +1062,7 @@ constexpr auto decimal32::operator+=(decimal32 rhs) noexcept -> decimal32& return *this; } -template +template constexpr auto decimal32::operator+=(Integer rhs) noexcept -> std::enable_if_t, decimal32&> { @@ -1070,7 +1070,7 @@ constexpr auto decimal32::operator+=(Integer rhs) noexcept return *this; } -template +template constexpr auto decimal32::operator+=(Decimal rhs) noexcept -> std::enable_if_t, decimal32&> { @@ -1111,7 +1111,7 @@ constexpr auto operator-(decimal32 lhs, decimal32 rhs) noexcept -> decimal32 return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator-(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32> { if (isinf(lhs) || isnan(lhs)) @@ -1144,7 +1144,7 @@ constexpr auto operator-(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_ return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator-(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32> { if (isinf(rhs) || isnan(rhs)) @@ -1195,7 +1195,7 @@ constexpr auto decimal32::operator-=(decimal32 rhs) noexcept -> decimal32& return *this; } -template +template constexpr auto decimal32::operator-=(Decimal rhs) noexcept -> std::enable_if_t, decimal32&> { @@ -1203,7 +1203,7 @@ constexpr auto decimal32::operator-=(Decimal rhs) noexcept return *this; } -template +template constexpr auto decimal32::operator-=(Integer rhs) noexcept -> std::enable_if_t, decimal32&> { @@ -1222,13 +1222,13 @@ constexpr auto operator==(decimal32 lhs, decimal32 rhs) noexcept -> bool rhs.full_significand(), rhs.biased_exponent(), rhs.isneg()); } -template +template constexpr auto operator==(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { return mixed_equality_impl(lhs, rhs); } -template +template constexpr auto operator==(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool> { return mixed_equality_impl(rhs, lhs); @@ -1239,13 +1239,13 @@ constexpr auto operator!=(decimal32 lhs, decimal32 rhs) noexcept -> bool return !(lhs == rhs); } -template +template constexpr auto operator!=(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { return !(lhs == rhs); } -template +template constexpr auto operator!=(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool> { return !(lhs == rhs); @@ -1278,13 +1278,13 @@ constexpr auto operator<(decimal32 lhs, decimal32 rhs) noexcept -> bool rhs.full_significand(), rhs.biased_exponent(), rhs.isneg()); } -template +template constexpr auto operator<(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { return less_impl(lhs, rhs); } -template +template constexpr auto operator<(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool> { if (isnan(rhs)) @@ -1305,7 +1305,7 @@ constexpr auto operator<=(decimal32 lhs, decimal32 rhs) noexcept -> bool return !(rhs < lhs); } -template +template constexpr auto operator<=(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { if (isnan(lhs)) @@ -1316,7 +1316,7 @@ constexpr auto operator<=(decimal32 lhs, Integer rhs) noexcept -> std::enable_if return !(rhs < lhs); } -template +template constexpr auto operator<=(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool> { if (isnan(rhs)) @@ -1332,7 +1332,7 @@ constexpr auto operator>(decimal32 lhs, decimal32 rhs) noexcept -> bool return rhs < lhs; } -template +template constexpr auto operator>(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { if (isnan(lhs)) @@ -1343,7 +1343,7 @@ constexpr auto operator>(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_ return rhs < lhs; } -template +template constexpr auto operator>(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool> { if (isnan(rhs)) @@ -1364,7 +1364,7 @@ constexpr auto operator>=(decimal32 lhs, decimal32 rhs) noexcept -> bool return !(lhs < rhs); } -template +template constexpr auto operator>=(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { if (isnan(lhs)) @@ -1375,7 +1375,7 @@ constexpr auto operator>=(decimal32 lhs, Integer rhs) noexcept -> std::enable_if return !(lhs < rhs); } -template +template constexpr auto operator>=(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, bool> { if (isnan(rhs)) @@ -1406,7 +1406,7 @@ constexpr auto operator<=>(decimal32 lhs, decimal32 rhs) noexcept -> std::partia return std::partial_ordering::unordered; } -template +template constexpr auto operator<=>(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, std::partial_ordering> { if (lhs < rhs) @@ -1425,7 +1425,7 @@ constexpr auto operator<=>(decimal32 lhs, Integer rhs) noexcept -> std::enable_i return std::partial_ordering::unordered; } -template +template constexpr auto operator<=>(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, std::partial_ordering> { if (lhs < rhs) @@ -1566,13 +1566,13 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal32::decimal32(Float val) noexcept } } -template , bool>> +template , bool>> constexpr decimal32::decimal32(Decimal val) noexcept { - *this = to_decimal(val); + *this = to_decimal(val); } -template , bool>> +template , bool>> constexpr decimal32::decimal32(Integer val) noexcept // NOLINT : Incorrect parameter is never used { using ConversionType = std::conditional_t::value, std::int32_t, Integer>; @@ -1655,7 +1655,7 @@ constexpr decimal32::operator detail::uint128_t() const noexcept #endif -template , bool>> +template , bool>> constexpr decimal32::operator Decimal() const noexcept { return to_decimal(*this); @@ -1734,7 +1734,7 @@ constexpr auto operator*(decimal32 lhs, decimal32 rhs) noexcept -> decimal32 return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator*(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32> { if (isnan(lhs) || isinf(lhs)) @@ -1759,7 +1759,7 @@ constexpr auto operator*(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_ return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator*(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32> { return rhs * lhs; @@ -1771,7 +1771,7 @@ constexpr auto decimal32::operator*=(decimal32 rhs) noexcept -> decimal32& return *this; } -template +template constexpr auto decimal32::operator*=(Integer rhs) noexcept -> std::enable_if_t, decimal32&> { @@ -1779,7 +1779,7 @@ constexpr auto decimal32::operator*=(Integer rhs) noexcept return *this; } -template +template constexpr auto decimal32::operator*=(Decimal rhs) noexcept -> std::enable_if_t, decimal32&> { @@ -1913,7 +1913,7 @@ constexpr auto operator/(decimal32 lhs, decimal32 rhs) noexcept -> decimal32 return q; } -template +template constexpr auto operator/(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32> { // Check pre-conditions @@ -1956,7 +1956,7 @@ constexpr auto operator/(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_ return decimal32(q_components.sig, q_components.exp, q_components.sign); } -template +template constexpr auto operator/(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32> { // Check pre-conditions @@ -2004,7 +2004,7 @@ constexpr auto decimal32::operator/=(decimal32 rhs) noexcept -> decimal32& return *this; } -template +template constexpr auto decimal32::operator/=(Integer rhs) noexcept -> std::enable_if_t, decimal32&> { @@ -2012,7 +2012,7 @@ constexpr auto decimal32::operator/=(Integer rhs) noexcept return *this; } -template +template constexpr auto decimal32::operator/=(Decimal rhs) noexcept -> std::enable_if_t, decimal32&> { @@ -2095,14 +2095,14 @@ constexpr auto operator&(decimal32 lhs, decimal32 rhs) noexcept -> decimal32 return from_bits(lhs.bits_ & rhs.bits_); } -template +template constexpr auto operator&(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32> { return from_bits(lhs.bits_ & static_cast(rhs)); } -template +template constexpr auto operator&(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32> { @@ -2114,14 +2114,14 @@ constexpr auto operator|(decimal32 lhs, decimal32 rhs) noexcept -> decimal32 return from_bits(lhs.bits_ | rhs.bits_); } -template +template constexpr auto operator|(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32> { return from_bits(lhs.bits_ | static_cast(rhs)); } -template +template constexpr auto operator|(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32> { @@ -2133,14 +2133,14 @@ constexpr auto operator^(decimal32 lhs, decimal32 rhs) noexcept -> decimal32 return from_bits(lhs.bits_ ^ rhs.bits_); } -template +template constexpr auto operator^(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32> { return from_bits(lhs.bits_ ^ static_cast(rhs)); } -template +template constexpr auto operator^(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32> { @@ -2152,14 +2152,14 @@ constexpr auto operator<<(decimal32 lhs, decimal32 rhs) noexcept -> decimal32 return from_bits(lhs.bits_ << rhs.bits_); } -template +template constexpr auto operator<<(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32> { return from_bits(lhs.bits_ << static_cast(rhs)); } -template +template constexpr auto operator<<(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32> { @@ -2171,14 +2171,14 @@ constexpr auto operator>>(decimal32 lhs, decimal32 rhs) noexcept -> decimal32 return from_bits(lhs.bits_ >> rhs.bits_); } -template +template constexpr auto operator>>(decimal32 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal32> { return from_bits(lhs.bits_ >> static_cast(rhs)); } -template +template constexpr auto operator>>(Integer lhs, decimal32 rhs) noexcept -> std::enable_if_t, decimal32> { diff --git a/include/boost/decimal/decimal64.hpp b/include/boost/decimal/decimal64.hpp index a1fbb3e99..e40346091 100644 --- a/include/boost/decimal/decimal64.hpp +++ b/include/boost/decimal/decimal64.hpp @@ -151,13 +151,13 @@ class decimal64 final // Attempts conversion to integral type: // If this is nan sets errno to EINVAL and returns 0 // If this is not representable sets errno to ERANGE and returns 0 - template + template friend constexpr auto to_integral(Decimal val) noexcept -> TargetType; - template + template friend BOOST_DECIMAL_CXX20_CONSTEXPR auto to_float(Decimal val) noexcept -> TargetType; - template + template friend constexpr auto to_decimal(Decimal val) noexcept -> TargetType; // Debug bit pattern @@ -165,21 +165,21 @@ class decimal64 final friend constexpr auto to_bits(decimal64 rhs) noexcept -> std::uint64_t; // Equality template between any integer type and decimal64 - template + template friend constexpr auto mixed_equality_impl(Decimal lhs, Integer rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_integral_v), bool>; - template + template friend constexpr auto mixed_decimal_equality_impl(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool>; // Template to compare operator< for any integer type and decimal64 - template + template friend constexpr auto less_impl(Decimal lhs, Integer rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_integral_v), bool>; - template + template friend constexpr auto mixed_decimal_less_impl(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool>; @@ -205,10 +205,10 @@ class decimal64 final friend constexpr auto d64_mod_impl(decimal64 lhs, decimal64 rhs, const decimal64& q, decimal64& r) noexcept -> void; - template + template friend constexpr auto ilogb(T d) noexcept -> std::enable_if_t, int>; - template + template friend constexpr auto logb(T num) noexcept -> std::enable_if_t, T>; public: @@ -219,11 +219,11 @@ class decimal64 final template , bool> = true> explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal64(Float val) noexcept; - template , bool> = true> + template , bool> = true> constexpr decimal64(Decimal val) noexcept; // 3.2.3.3 Conversion from integral type - template , bool> = true> + template , bool> = true> explicit constexpr decimal64(Integer val) noexcept; // 3.2.3.4 Conversion to integral type @@ -245,7 +245,7 @@ class decimal64 final #endif - template , bool> = true> + template , bool> = true> explicit constexpr operator Decimal() const noexcept; // 3.2.6 Conversion to floating-point type @@ -287,41 +287,41 @@ class decimal64 final // 3.2.8 Binary arithmetic operators friend constexpr auto operator+(decimal64 lhs, decimal64 rhs) noexcept -> decimal64; - template + template friend constexpr auto operator+(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64>; - template + template friend constexpr auto operator+(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64>; friend constexpr auto operator-(decimal64 lhs, decimal64 rhs) noexcept -> decimal64; - template + template friend constexpr auto operator-(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64>; - template + template friend constexpr auto operator-(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64>; friend constexpr auto operator*(decimal64 lhs, decimal64 rhs) noexcept -> decimal64; - template + template friend constexpr auto operator*(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64>; - template + template friend constexpr auto operator*(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64>; friend constexpr auto operator/(decimal64 lhs, decimal64 rhs) noexcept -> decimal64; - template + template friend constexpr auto operator/(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64>; - template + template friend constexpr auto operator/(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64>; @@ -336,41 +336,41 @@ class decimal64 final // 3.2.3.6 Compound assignment constexpr auto operator+=(decimal64 rhs) noexcept -> decimal64&; - template + template constexpr auto operator+=(Integer rhs) noexcept -> std::enable_if_t, decimal64&>; - template + template constexpr auto operator+=(Decimal rhs) noexcept -> std::enable_if_t, decimal64&>; constexpr auto operator-=(decimal64 rhs) noexcept -> decimal64&; - template + template constexpr auto operator-=(Integer rhs) noexcept -> std::enable_if_t, decimal64&>; - template + template constexpr auto operator-=(Decimal rhs) noexcept -> std::enable_if_t, decimal64&>; constexpr auto operator*=(decimal64 rhs) noexcept -> decimal64&; - template + template constexpr auto operator*=(Integer rhs) noexcept -> std::enable_if_t, decimal64&>; - template + template constexpr auto operator*=(Decimal rhs) noexcept -> std::enable_if_t, decimal64&>; constexpr auto operator/=(decimal64 rhs) noexcept -> decimal64&; - template + template constexpr auto operator/=(Integer rhs) noexcept -> std::enable_if_t, decimal64&>; - template + template constexpr auto operator/=(Decimal rhs) noexcept -> std::enable_if_t, decimal64&>; @@ -378,66 +378,66 @@ class decimal64 final // Equality friend constexpr auto operator==(decimal64 lhs, decimal64 rhs) noexcept -> bool; - template + template friend constexpr auto operator==(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator==(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool>; // Inequality friend constexpr auto operator!=(decimal64 lhs, decimal64 rhs) noexcept -> bool; - template + template friend constexpr auto operator!=(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator!=(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool>; // Less friend constexpr auto operator<(decimal64 lhs, decimal64 rhs) noexcept -> bool; - template + template friend constexpr auto operator<(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator<(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool>; // Less equal friend constexpr auto operator<=(decimal64 lhs, decimal64 rhs) noexcept -> bool; - template + template friend constexpr auto operator<=(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator<=(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool>; // Greater friend constexpr auto operator>(decimal64 lhs, decimal64 rhs) noexcept -> bool; - template + template friend constexpr auto operator>(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator>(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool>; // Greater equal friend constexpr auto operator>=(decimal64 lhs, decimal64 rhs) noexcept -> bool; - template + template friend constexpr auto operator>=(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool>; - template + template friend constexpr auto operator>=(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool>; @@ -445,21 +445,21 @@ class decimal64 final #ifdef BOOST_DECIMAL_HAS_SPACESHIP_OPERATOR friend constexpr auto operator<=>(decimal64 lhs, decimal64 rhs) noexcept -> std::partial_ordering; - template + template friend constexpr auto operator<=>(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, std::partial_ordering>; - template + template friend constexpr auto operator<=>(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, std::partial_ordering>; #endif #if !defined(BOOST_DECIMAL_DISABLE_IOSTREAM) // 3.2.10 Formatted input: - template + template friend auto operator>>(std::basic_istream& is, DecimalType& d) -> std::enable_if_t, std::basic_istream&>; // 3.2.11 Formatted output: - template + template friend auto operator<<(std::basic_ostream& os, const DecimalType& d) -> std::enable_if_t, std::basic_ostream&>; #endif @@ -476,58 +476,58 @@ class decimal64 final // Bit-wise operators friend constexpr auto operator&(decimal64 lhs, decimal64 rhs) noexcept -> decimal64; - template + template friend constexpr auto operator&(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64>; - template + template friend constexpr auto operator&(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64>; friend constexpr auto operator|(decimal64 lhs, decimal64 rhs) noexcept -> decimal64; - template + template friend constexpr auto operator|(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64>; - template + template friend constexpr auto operator|(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64>; friend constexpr auto operator^(decimal64 lhs, decimal64 rhs) noexcept -> decimal64; - template + template friend constexpr auto operator^(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64>; - template + template friend constexpr auto operator^(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64>; friend constexpr auto operator<<(decimal64 lhs, decimal64 rhs) noexcept -> decimal64; - template + template friend constexpr auto operator<<(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64>; - template + template friend constexpr auto operator<<(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64>; friend constexpr auto operator>>(decimal64 lhs, decimal64 rhs) noexcept -> decimal64; - template + template friend constexpr auto operator>>(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64>; - template + template friend constexpr auto operator>>(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64>; friend constexpr auto operator~(decimal64 lhs) noexcept -> decimal64; // functions that need to be friends - template + template friend constexpr auto frexp10(T num, int* expptr) noexcept -> std::enable_if_t, std::conditional_t::value, std::uint32_t, @@ -741,13 +741,13 @@ BOOST_DECIMAL_CXX20_CONSTEXPR decimal64::decimal64(Float val) noexcept } } -template , bool>> +template , bool>> constexpr decimal64::decimal64(Decimal val) noexcept { *this = to_decimal(val); } -template , bool>> +template , bool>> constexpr decimal64::decimal64(Integer val) noexcept // NOLINT : Incorrect parameter is never used { using ConversionType = std::conditional_t::value, std::int32_t, Integer>; @@ -831,7 +831,7 @@ constexpr decimal64::operator detail::uint128_t() const noexcept #endif -template , bool>> +template , bool>> constexpr decimal64::operator Decimal() const noexcept { return to_decimal(*this); @@ -1362,7 +1362,7 @@ constexpr auto operator+(decimal64 lhs, decimal64 rhs) noexcept -> decimal64 return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator+(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64> { @@ -1420,7 +1420,7 @@ constexpr auto operator+(decimal64 lhs, Integer rhs) noexcept return decimal64(result.sig, result.exp, result.sign); } -template +template constexpr auto operator+(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64> { @@ -1460,7 +1460,7 @@ constexpr auto operator-(decimal64 lhs, decimal64 rhs) noexcept -> decimal64 return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator-(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64> { @@ -1494,7 +1494,7 @@ constexpr auto operator-(decimal64 lhs, Integer rhs) noexcept return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator-(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64> { @@ -1552,7 +1552,7 @@ constexpr auto operator*(decimal64 lhs, decimal64 rhs) noexcept -> decimal64 return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator*(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64> { @@ -1578,7 +1578,7 @@ constexpr auto operator*(decimal64 lhs, Integer rhs) noexcept return {result.sig, result.exp, result.sign}; } -template +template constexpr auto operator*(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64> { @@ -1594,7 +1594,7 @@ constexpr auto operator/(decimal64 lhs, decimal64 rhs) noexcept -> decimal64 return q; } -template +template constexpr auto operator/(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64> { // Check pre-conditions @@ -1639,7 +1639,7 @@ constexpr auto operator/(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_ return decimal64(q_components.sig, q_components.exp, q_components.sign); } -template +template constexpr auto operator/(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64> { // Check pre-conditions @@ -1719,7 +1719,7 @@ constexpr auto decimal64::operator+=(decimal64 rhs) noexcept -> decimal64& return *this; } -template +template constexpr auto decimal64::operator+=(Integer rhs) noexcept -> std::enable_if_t, decimal64&> { @@ -1727,7 +1727,7 @@ constexpr auto decimal64::operator+=(Integer rhs) noexcept return *this; } -template +template constexpr auto decimal64::operator+=(Decimal rhs) noexcept -> std::enable_if_t, decimal64&> { @@ -1741,7 +1741,7 @@ constexpr auto decimal64::operator-=(decimal64 rhs) noexcept -> decimal64& return *this; } -template +template constexpr auto decimal64::operator-=(Integer rhs) noexcept -> std::enable_if_t, decimal64&> { @@ -1749,7 +1749,7 @@ constexpr auto decimal64::operator-=(Integer rhs) noexcept return *this; } -template +template constexpr auto decimal64::operator-=(Decimal rhs) noexcept -> std::enable_if_t, decimal64&> { @@ -1763,7 +1763,7 @@ constexpr auto decimal64::operator*=(decimal64 rhs) noexcept -> decimal64& return *this; } -template +template constexpr auto decimal64::operator*=(Integer rhs) noexcept -> std::enable_if_t, decimal64&> { @@ -1771,7 +1771,7 @@ constexpr auto decimal64::operator*=(Integer rhs) noexcept return *this; } -template +template constexpr auto decimal64::operator*=(Decimal rhs) noexcept -> std::enable_if_t, decimal64&> { @@ -1785,7 +1785,7 @@ constexpr auto decimal64::operator/=(decimal64 rhs) noexcept -> decimal64& return *this; } -template +template constexpr auto decimal64::operator/=(Integer rhs) noexcept -> std::enable_if_t, decimal64&> { @@ -1793,7 +1793,7 @@ constexpr auto decimal64::operator/=(Integer rhs) noexcept return *this; } -template +template constexpr auto decimal64::operator/=(Decimal rhs) noexcept -> std::enable_if_t, decimal64&> { @@ -1813,14 +1813,14 @@ constexpr auto operator==(decimal64 lhs, decimal64 rhs) noexcept -> bool rhs.full_significand(), rhs.biased_exponent(), rhs.isneg()); } -template +template constexpr auto operator==(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { return mixed_equality_impl(lhs, rhs); } -template +template constexpr auto operator==(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool> { @@ -1832,14 +1832,14 @@ constexpr auto operator!=(decimal64 lhs, decimal64 rhs) noexcept -> bool return !(lhs == rhs); } -template +template constexpr auto operator!=(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { return !(lhs == rhs); } -template +template constexpr auto operator!=(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool> { @@ -1873,14 +1873,14 @@ constexpr auto operator<(decimal64 lhs, decimal64 rhs) noexcept -> bool rhs.full_significand(), rhs.biased_exponent(), rhs.isneg()); } -template +template constexpr auto operator<(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { return less_impl(lhs, rhs); } -template +template constexpr auto operator<(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool> { @@ -1902,7 +1902,7 @@ constexpr auto operator<=(decimal64 lhs, decimal64 rhs) noexcept -> bool return !(rhs < lhs); } -template +template constexpr auto operator<=(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { @@ -1914,7 +1914,7 @@ constexpr auto operator<=(decimal64 lhs, Integer rhs) noexcept return !(rhs < lhs); } -template +template constexpr auto operator<=(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool> { @@ -1931,14 +1931,14 @@ constexpr auto operator>(decimal64 lhs, decimal64 rhs) noexcept -> bool return rhs < lhs; } -template +template constexpr auto operator>(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { return rhs < lhs; } -template +template constexpr auto operator>(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool> { @@ -1955,7 +1955,7 @@ constexpr auto operator>=(decimal64 lhs, decimal64 rhs) noexcept -> bool return !(lhs < rhs); } -template +template constexpr auto operator>=(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, bool> { @@ -1967,7 +1967,7 @@ constexpr auto operator>=(decimal64 lhs, Integer rhs) noexcept return !(lhs < rhs); } -template +template constexpr auto operator>=(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, bool> { @@ -1999,7 +1999,7 @@ constexpr auto operator<=>(decimal64 lhs, decimal64 rhs) noexcept -> std::partia return std::partial_ordering::unordered; } -template +template constexpr auto operator<=>(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, std::partial_ordering> { if (lhs < rhs) @@ -2018,7 +2018,7 @@ constexpr auto operator<=>(decimal64 lhs, Integer rhs) noexcept -> std::enable_i return std::partial_ordering::unordered; } -template +template constexpr auto operator<=>(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, std::partial_ordering> { if (lhs < rhs) @@ -2044,14 +2044,14 @@ constexpr auto operator&(decimal64 lhs, decimal64 rhs) noexcept -> decimal64 return from_bits(lhs.bits_ & rhs.bits_); } -template +template constexpr auto operator&(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64> { return from_bits(lhs.bits_ & static_cast(rhs)); } -template +template constexpr auto operator&(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64> { @@ -2063,14 +2063,14 @@ constexpr auto operator|(decimal64 lhs, decimal64 rhs) noexcept -> decimal64 return from_bits(lhs.bits_ | rhs.bits_); } -template +template constexpr auto operator|(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64> { return from_bits(lhs.bits_ | static_cast(rhs)); } -template +template constexpr auto operator|(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64> { @@ -2082,14 +2082,14 @@ constexpr auto operator^(decimal64 lhs, decimal64 rhs) noexcept -> decimal64 return from_bits(lhs.bits_ ^ rhs.bits_); } -template +template constexpr auto operator^(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64> { return from_bits(lhs.bits_ ^ static_cast(rhs)); } -template +template constexpr auto operator^(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64> { @@ -2101,14 +2101,14 @@ constexpr auto operator<<(decimal64 lhs, decimal64 rhs) noexcept -> decimal64 return from_bits(lhs.bits_ << rhs.bits_); } -template +template constexpr auto operator<<(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64> { return from_bits(lhs.bits_ << static_cast(rhs)); } -template +template constexpr auto operator<<(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64> { @@ -2120,14 +2120,14 @@ constexpr auto operator>>(decimal64 lhs, decimal64 rhs) noexcept -> decimal64 return from_bits(lhs.bits_ >> rhs.bits_); } -template +template constexpr auto operator>>(decimal64 lhs, Integer rhs) noexcept -> std::enable_if_t, decimal64> { return from_bits(lhs.bits_ >> static_cast(rhs)); } -template +template constexpr auto operator>>(Integer lhs, decimal64 rhs) noexcept -> std::enable_if_t, decimal64> { diff --git a/include/boost/decimal/detail/cmath/abs.hpp b/include/boost/decimal/detail/cmath/abs.hpp index 317c2394e..56efa013d 100644 --- a/include/boost/decimal/detail/cmath/abs.hpp +++ b/include/boost/decimal/detail/cmath/abs.hpp @@ -8,12 +8,14 @@ #include #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto abs BOOST_DECIMAL_PREVENT_MACRO_SUBSTITUTION (T rhs) noexcept -> std::enable_if_t, T> { diff --git a/include/boost/decimal/detail/cmath/acosh.hpp b/include/boost/decimal/detail/cmath/acosh.hpp index 0a704e464..54422f1f1 100644 --- a/include/boost/decimal/detail/cmath/acosh.hpp +++ b/include/boost/decimal/detail/cmath/acosh.hpp @@ -11,11 +11,13 @@ #include // NOLINT(llvm-include-order) #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto acosh(T x) noexcept -> std::enable_if_t, T> { const auto fpc = fpclassify(x); diff --git a/include/boost/decimal/detail/cmath/asinh.hpp b/include/boost/decimal/detail/cmath/asinh.hpp index 893271836..b259f8d38 100644 --- a/include/boost/decimal/detail/cmath/asinh.hpp +++ b/include/boost/decimal/detail/cmath/asinh.hpp @@ -11,11 +11,13 @@ #include // NOLINT(llvm-include-order) #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto asinh(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { T result { }; diff --git a/include/boost/decimal/detail/cmath/atanh.hpp b/include/boost/decimal/detail/cmath/atanh.hpp index 827622738..51b00bb28 100644 --- a/include/boost/decimal/detail/cmath/atanh.hpp +++ b/include/boost/decimal/detail/cmath/atanh.hpp @@ -11,11 +11,13 @@ #include // NOLINT(llvm-include-order) #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto atanh(T x) noexcept -> std::enable_if_t, T> { T result { }; diff --git a/include/boost/decimal/detail/cmath/ceil.hpp b/include/boost/decimal/detail/cmath/ceil.hpp index 6748f973a..bce54fc03 100644 --- a/include/boost/decimal/detail/cmath/ceil.hpp +++ b/include/boost/decimal/detail/cmath/ceil.hpp @@ -10,14 +10,16 @@ #include #include #include +#include #include #include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto ceil BOOST_DECIMAL_PREVENT_MACRO_SUBSTITUTION (T val) noexcept -> std::enable_if_t, T> { diff --git a/include/boost/decimal/detail/cmath/cos.hpp b/include/boost/decimal/detail/cmath/cos.hpp index b7e6a8305..5d430ee55 100644 --- a/include/boost/decimal/detail/cmath/cos.hpp +++ b/include/boost/decimal/detail/cmath/cos.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -16,9 +17,10 @@ #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto cos(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { T result { }; diff --git a/include/boost/decimal/detail/cmath/cosh.hpp b/include/boost/decimal/detail/cmath/cosh.hpp index beaa14c25..d90849c7e 100644 --- a/include/boost/decimal/detail/cmath/cosh.hpp +++ b/include/boost/decimal/detail/cmath/cosh.hpp @@ -11,11 +11,13 @@ #include // NOLINT(llvm-include-order) #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto cosh(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { const auto fpc = fpclassify(x); diff --git a/include/boost/decimal/detail/cmath/exp.hpp b/include/boost/decimal/detail/cmath/exp.hpp index 49f1e67d7..9e48170f7 100644 --- a/include/boost/decimal/detail/cmath/exp.hpp +++ b/include/boost/decimal/detail/cmath/exp.hpp @@ -12,11 +12,13 @@ #include // NOLINT(llvm-include-order) #include #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto exp(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { const auto fpc = fpclassify(x); diff --git a/include/boost/decimal/detail/cmath/exp2.hpp b/include/boost/decimal/detail/cmath/exp2.hpp index 8cab78bc5..bbddfa0ca 100644 --- a/include/boost/decimal/detail/cmath/exp2.hpp +++ b/include/boost/decimal/detail/cmath/exp2.hpp @@ -6,12 +6,13 @@ #define BOOST_DECIMAL_DETAIL_CMATH_EXP2_HPP #include +#include #include namespace boost { namespace decimal { -template +template constexpr auto exp2(T num) noexcept -> std::enable_if_t, T> { constexpr T two {2, 0}; diff --git a/include/boost/decimal/detail/cmath/expm1.hpp b/include/boost/decimal/detail/cmath/expm1.hpp index f9d7e9ef9..c71bd4dfe 100644 --- a/include/boost/decimal/detail/cmath/expm1.hpp +++ b/include/boost/decimal/detail/cmath/expm1.hpp @@ -11,11 +11,13 @@ #include // NOLINT(llvm-include-order) #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto expm1(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { const auto fpc = fpclassify(x); diff --git a/include/boost/decimal/detail/cmath/fabs.hpp b/include/boost/decimal/detail/cmath/fabs.hpp index 7ae2d2506..19bee4b50 100644 --- a/include/boost/decimal/detail/cmath/fabs.hpp +++ b/include/boost/decimal/detail/cmath/fabs.hpp @@ -7,15 +7,15 @@ #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -// TODO(mborland): Allow conversion between decimal types via a promotion system - -template, bool> = true> -constexpr auto fabs(T a) noexcept -> T +template +constexpr auto fabs(T a) noexcept -> std::enable_if_t, T> { return abs(a); } diff --git a/include/boost/decimal/detail/cmath/fdim.hpp b/include/boost/decimal/detail/cmath/fdim.hpp index 9d3e473d4..545b2eb8b 100644 --- a/include/boost/decimal/detail/cmath/fdim.hpp +++ b/include/boost/decimal/detail/cmath/fdim.hpp @@ -7,14 +7,16 @@ #include #include +#include #include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template, bool> = true> -constexpr auto fdim(T x, T y) noexcept -> T +template +constexpr auto fdim(T x, T y) noexcept -> std::enable_if_t, T> { constexpr T zero {0, 0}; diff --git a/include/boost/decimal/detail/cmath/floor.hpp b/include/boost/decimal/detail/cmath/floor.hpp index 8915d87ba..a13602925 100644 --- a/include/boost/decimal/detail/cmath/floor.hpp +++ b/include/boost/decimal/detail/cmath/floor.hpp @@ -13,12 +13,14 @@ #include #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto floor BOOST_DECIMAL_PREVENT_MACRO_SUBSTITUTION (T val) noexcept -> std::enable_if_t, T> { diff --git a/include/boost/decimal/detail/cmath/fmax.hpp b/include/boost/decimal/detail/cmath/fmax.hpp index a79367552..b7f98b4b7 100644 --- a/include/boost/decimal/detail/cmath/fmax.hpp +++ b/include/boost/decimal/detail/cmath/fmax.hpp @@ -7,15 +7,16 @@ #include #include +#include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -// TODO(mborland): Allow conversion between decimal types via a promotion system - -template, bool> = true> -constexpr auto fmax(T lhs, T rhs) noexcept -> T +template +constexpr auto fmax(T lhs, T rhs) noexcept -> std::enable_if_t, T> { if (isnan(lhs) && !isnan(rhs)) { diff --git a/include/boost/decimal/detail/cmath/fmin.hpp b/include/boost/decimal/detail/cmath/fmin.hpp index adb8fe8ad..e60056b3d 100644 --- a/include/boost/decimal/detail/cmath/fmin.hpp +++ b/include/boost/decimal/detail/cmath/fmin.hpp @@ -7,13 +7,15 @@ #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template, bool> = true> -constexpr auto fmin(T lhs, T rhs) noexcept -> T +template +constexpr auto fmin(T lhs, T rhs) noexcept -> std::enable_if_t, T> { if (isnan(lhs) && !isnan(rhs)) { diff --git a/include/boost/decimal/detail/cmath/fmod.hpp b/include/boost/decimal/detail/cmath/fmod.hpp index 6f5ed3668..273f2ed78 100644 --- a/include/boost/decimal/detail/cmath/fmod.hpp +++ b/include/boost/decimal/detail/cmath/fmod.hpp @@ -7,12 +7,14 @@ #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto fmod(T lhs, T rhs) noexcept -> std::enable_if_t, T> { return lhs % rhs; diff --git a/include/boost/decimal/detail/cmath/fpclassify.hpp b/include/boost/decimal/detail/cmath/fpclassify.hpp index 737b23efd..7dbb70300 100644 --- a/include/boost/decimal/detail/cmath/fpclassify.hpp +++ b/include/boost/decimal/detail/cmath/fpclassify.hpp @@ -8,12 +8,14 @@ #include #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto fpclassify BOOST_DECIMAL_PREVENT_MACRO_SUBSTITUTION (T rhs) noexcept -> std::enable_if_t, int> { diff --git a/include/boost/decimal/detail/cmath/frexp.hpp b/include/boost/decimal/detail/cmath/frexp.hpp index 6d1dc295f..e0c45855d 100644 --- a/include/boost/decimal/detail/cmath/frexp.hpp +++ b/include/boost/decimal/detail/cmath/frexp.hpp @@ -12,11 +12,13 @@ #include // NOLINT(llvm-include-order) #include #include +#include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template, bool> = true> -constexpr auto frexp(T v, int* expon) noexcept -> T +template +constexpr auto frexp(T v, int* expon) noexcept -> std::enable_if_t, T> { // This implementation of frexp follows closely that of eval_frexp // in Boost.Multiprecision's cpp_dec_float template class. diff --git a/include/boost/decimal/detail/cmath/frexp10.hpp b/include/boost/decimal/detail/cmath/frexp10.hpp index fd35b6ddc..2a70fe0a0 100644 --- a/include/boost/decimal/detail/cmath/frexp10.hpp +++ b/include/boost/decimal/detail/cmath/frexp10.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace boost { namespace decimal { @@ -19,7 +20,7 @@ namespace decimal { // Returns num in the range [1'000'000, 9'999'999] // // If the conversion can not be performed returns UINT32_MAX and exp = 0 -template +template constexpr auto frexp10(T num, int* expptr) noexcept -> std::enable_if_t, std::conditional_t::value, std::uint32_t, diff --git a/include/boost/decimal/detail/cmath/hypot.hpp b/include/boost/decimal/detail/cmath/hypot.hpp index 919832d5e..a5974f631 100644 --- a/include/boost/decimal/detail/cmath/hypot.hpp +++ b/include/boost/decimal/detail/cmath/hypot.hpp @@ -11,12 +11,14 @@ #include #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto hypot(T x, T y) noexcept -> std::enable_if_t, T> { constexpr T zero {0, 0}; @@ -60,7 +62,7 @@ constexpr auto hypot(T x, T y) noexcept -> std::enable_if_t +template constexpr auto hypot(T x, T y, T z) noexcept -> std::enable_if_t, T> { if (isinf(x) || isinf(y) || isinf(z)) diff --git a/include/boost/decimal/detail/cmath/ilogb.hpp b/include/boost/decimal/detail/cmath/ilogb.hpp index 13959a204..d807b3dd2 100644 --- a/include/boost/decimal/detail/cmath/ilogb.hpp +++ b/include/boost/decimal/detail/cmath/ilogb.hpp @@ -10,11 +10,12 @@ #include // NOLINT(llvm-include-order) #include +#include namespace boost { namespace decimal { -template +template constexpr auto ilogb(T d) noexcept -> std::enable_if_t, int> { const auto fpc_d = fpclassify(d); diff --git a/include/boost/decimal/detail/cmath/isfinite.hpp b/include/boost/decimal/detail/cmath/isfinite.hpp index 20a51c01f..57fcca73a 100644 --- a/include/boost/decimal/detail/cmath/isfinite.hpp +++ b/include/boost/decimal/detail/cmath/isfinite.hpp @@ -8,12 +8,14 @@ #include #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto isfinite BOOST_DECIMAL_PREVENT_MACRO_SUBSTITUTION (T rhs) noexcept -> std::enable_if_t, bool> { diff --git a/include/boost/decimal/detail/cmath/isgreater.hpp b/include/boost/decimal/detail/cmath/isgreater.hpp index 2ab369766..e659e5218 100644 --- a/include/boost/decimal/detail/cmath/isgreater.hpp +++ b/include/boost/decimal/detail/cmath/isgreater.hpp @@ -7,13 +7,15 @@ #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template , bool> = true> -constexpr auto isgreater(T lhs, T rhs) noexcept -> bool +template +constexpr auto isgreater(T lhs, T rhs) noexcept -> std::enable_if_t, bool> { if (isnan(lhs) || isnan(rhs)) { @@ -23,8 +25,8 @@ constexpr auto isgreater(T lhs, T rhs) noexcept -> bool return lhs > rhs; } -template , bool> = true> -constexpr auto isgreaterequal(T lhs, T rhs) noexcept -> bool +template +constexpr auto isgreaterequal(T lhs, T rhs) noexcept -> std::enable_if_t, bool> { if (isnan(lhs) || isnan(rhs)) { diff --git a/include/boost/decimal/detail/cmath/isless.hpp b/include/boost/decimal/detail/cmath/isless.hpp index 0be05d501..2f7728b32 100644 --- a/include/boost/decimal/detail/cmath/isless.hpp +++ b/include/boost/decimal/detail/cmath/isless.hpp @@ -7,13 +7,15 @@ #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template , bool> = true> -constexpr auto isless(T lhs, T rhs) noexcept -> bool +template +constexpr auto isless(T lhs, T rhs) noexcept -> std::enable_if_t, bool> { if (isnan(lhs) || isnan(rhs)) { @@ -23,8 +25,8 @@ constexpr auto isless(T lhs, T rhs) noexcept -> bool return lhs < rhs; } -template , bool> = true> -constexpr auto islessequal(T lhs, T rhs) noexcept -> bool +template +constexpr auto islessequal(T lhs, T rhs) noexcept -> std::enable_if_t, bool> { if (isnan(lhs) || isnan(rhs)) { @@ -34,8 +36,8 @@ constexpr auto islessequal(T lhs, T rhs) noexcept -> bool return lhs <= rhs; } -template , bool> = true> -constexpr auto islessgreater(T lhs, T rhs) noexcept -> bool +template +constexpr auto islessgreater(T lhs, T rhs) noexcept -> std::enable_if_t, bool> { if (isnan(lhs) || isnan(rhs)) { diff --git a/include/boost/decimal/detail/cmath/isunordered.hpp b/include/boost/decimal/detail/cmath/isunordered.hpp index ed441ac29..a431188e2 100644 --- a/include/boost/decimal/detail/cmath/isunordered.hpp +++ b/include/boost/decimal/detail/cmath/isunordered.hpp @@ -7,13 +7,15 @@ #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template , bool> = true> -constexpr auto isunordered(T lhs, T rhs) noexcept -> bool +template +constexpr auto isunordered(T lhs, T rhs) noexcept -> std::enable_if_t, bool> { return isnan(lhs) || isnan(rhs); } diff --git a/include/boost/decimal/detail/cmath/ldexp.hpp b/include/boost/decimal/detail/cmath/ldexp.hpp index 9f4da1210..e753f924c 100644 --- a/include/boost/decimal/detail/cmath/ldexp.hpp +++ b/include/boost/decimal/detail/cmath/ldexp.hpp @@ -8,13 +8,15 @@ #include #include #include +#include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template, bool> = true> -constexpr auto ldexp(T v, int e2) noexcept -> T +template +constexpr auto ldexp(T v, int e2) noexcept -> std::enable_if_t, T> { T result { }; diff --git a/include/boost/decimal/detail/cmath/log.hpp b/include/boost/decimal/detail/cmath/log.hpp index 00b06f7f4..23610a03c 100644 --- a/include/boost/decimal/detail/cmath/log.hpp +++ b/include/boost/decimal/detail/cmath/log.hpp @@ -11,11 +11,13 @@ #include #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto log(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { constexpr T zero { 0, 0 }; diff --git a/include/boost/decimal/detail/cmath/log10.hpp b/include/boost/decimal/detail/cmath/log10.hpp index 3dbe5cd0f..8dfe6aa24 100644 --- a/include/boost/decimal/detail/cmath/log10.hpp +++ b/include/boost/decimal/detail/cmath/log10.hpp @@ -11,11 +11,13 @@ #include // NOLINT(llvm-include-order) #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto log10(T x) noexcept -> std::enable_if_t, T> { // TODO(ckormanyos) Actually this is eintirely preliminary. The implementation diff --git a/include/boost/decimal/detail/cmath/log1p.hpp b/include/boost/decimal/detail/cmath/log1p.hpp index cbfa1636e..06256036e 100644 --- a/include/boost/decimal/detail/cmath/log1p.hpp +++ b/include/boost/decimal/detail/cmath/log1p.hpp @@ -11,11 +11,13 @@ #include // NOLINT(llvm-include-order) #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto log1p(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { const auto fpc = fpclassify(x); diff --git a/include/boost/decimal/detail/cmath/logb.hpp b/include/boost/decimal/detail/cmath/logb.hpp index a96561cff..2055abfc3 100644 --- a/include/boost/decimal/detail/cmath/logb.hpp +++ b/include/boost/decimal/detail/cmath/logb.hpp @@ -10,11 +10,12 @@ #include // NOLINT(llvm-include-order) #include +#include namespace boost { namespace decimal { -template +template constexpr auto logb(T num) noexcept -> std::enable_if_t, T> { const auto fpc {fpclassify(num)}; diff --git a/include/boost/decimal/detail/cmath/modf.hpp b/include/boost/decimal/detail/cmath/modf.hpp index 0afd1d53f..77ecf4244 100644 --- a/include/boost/decimal/detail/cmath/modf.hpp +++ b/include/boost/decimal/detail/cmath/modf.hpp @@ -8,14 +8,16 @@ #include #include #include +#include #include #include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto modf(T x, T* iptr) noexcept -> std::enable_if_t, T> { constexpr T zero {0, 0}; diff --git a/include/boost/decimal/detail/cmath/nan.hpp b/include/boost/decimal/detail/cmath/nan.hpp index 3da61aae7..1f40d5314 100644 --- a/include/boost/decimal/detail/cmath/nan.hpp +++ b/include/boost/decimal/detail/cmath/nan.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -18,7 +19,7 @@ namespace decimal { namespace detail { -template +template constexpr auto nan_impl(const char* arg) noexcept -> TargetDecimalType { char* endptr {}; diff --git a/include/boost/decimal/detail/cmath/nearbyint.hpp b/include/boost/decimal/detail/cmath/nearbyint.hpp index 9b8bd8f27..156b82787 100644 --- a/include/boost/decimal/detail/cmath/nearbyint.hpp +++ b/include/boost/decimal/detail/cmath/nearbyint.hpp @@ -7,13 +7,14 @@ #include #include +#include #include #include namespace boost { namespace decimal { -template +template constexpr auto nearbyint(T num) noexcept -> std::enable_if_t, T> { return rint(num); diff --git a/include/boost/decimal/detail/cmath/next.hpp b/include/boost/decimal/detail/cmath/next.hpp index 665c4930c..77fd5dd0a 100644 --- a/include/boost/decimal/detail/cmath/next.hpp +++ b/include/boost/decimal/detail/cmath/next.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -22,7 +23,7 @@ namespace boost { namespace decimal { -template +template constexpr auto nextafter(T1 val, T2 direction) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v || detail::is_decimal_floating_point_v), detail::promote_args_t> @@ -43,7 +44,7 @@ constexpr auto nextafter(T1 val, T2 direction) noexcept return val - std::numeric_limits::epsilon(); } -template +template BOOST_DECIMAL_CXX20_CONSTEXPR auto nexttoward(T val, long double direction) noexcept -> std::enable_if_t, T> { diff --git a/include/boost/decimal/detail/cmath/pow.hpp b/include/boost/decimal/detail/cmath/pow.hpp index 56a757204..b6c769676 100644 --- a/include/boost/decimal/detail/cmath/pow.hpp +++ b/include/boost/decimal/detail/cmath/pow.hpp @@ -13,10 +13,14 @@ #include // NOLINT(llvm-include-order) #include #include +#include -namespace boost { namespace decimal { -template -constexpr auto pow(T b, IntegralType p) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && std::is_integral::value), T> // NOLINT(misc-no-recursion) +namespace boost { +namespace decimal { + +template +constexpr auto pow(T b, IntegralType p) noexcept + -> std::enable_if_t<(detail::is_decimal_floating_point_v && std::is_integral::value), T> // NOLINT(misc-no-recursion) { using local_integral_type = IntegralType; @@ -143,7 +147,7 @@ constexpr auto pow(T b, IntegralType p) noexcept -> std::enable_if_t<(detail::is return result; } -template +template constexpr auto pow(T x, T a) noexcept -> std::enable_if_t, T> { constexpr T zero { 0, 0 }; diff --git a/include/boost/decimal/detail/cmath/remainder.hpp b/include/boost/decimal/detail/cmath/remainder.hpp index 3fe5d6b07..4caf37caf 100644 --- a/include/boost/decimal/detail/cmath/remainder.hpp +++ b/include/boost/decimal/detail/cmath/remainder.hpp @@ -7,14 +7,16 @@ #include #include +#include #include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template, bool> = true> -constexpr auto remainder(T x, T y) noexcept -> T +template +constexpr auto remainder(T x, T y) noexcept -> std::enable_if_t, T> { constexpr T zero {0, 0}; constexpr T half {5, -1}; diff --git a/include/boost/decimal/detail/cmath/remquo.hpp b/include/boost/decimal/detail/cmath/remquo.hpp index 827cc70d3..7887a6477 100644 --- a/include/boost/decimal/detail/cmath/remquo.hpp +++ b/include/boost/decimal/detail/cmath/remquo.hpp @@ -7,13 +7,15 @@ #include #include +#include #include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto remquo(T x, T y, int* quo) noexcept -> std::enable_if_t, T> { constexpr T zero {0, 0}; diff --git a/include/boost/decimal/detail/cmath/rint.hpp b/include/boost/decimal/detail/cmath/rint.hpp index 58856b902..ebf88c088 100644 --- a/include/boost/decimal/detail/cmath/rint.hpp +++ b/include/boost/decimal/detail/cmath/rint.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -23,7 +24,7 @@ namespace decimal { namespace detail { -template +template constexpr auto rint_impl(T1& sig, T2 exp, bool sign) { sig /= detail::pow10(std::abs(exp) - 1); @@ -37,7 +38,7 @@ constexpr auto rint_impl(T1& sig, T2 exp, bool sign) # pragma warning(disable: 4146) #endif -template +template constexpr auto lrint_impl(T num) noexcept -> std::enable_if_t, Int> { constexpr T zero {0, 0}; @@ -94,7 +95,7 @@ constexpr auto lrint_impl(T num) noexcept -> std::enable_if_t +template constexpr auto rint(T num) noexcept -> std::enable_if_t, T> { constexpr T zero {0, 0}; @@ -122,13 +123,13 @@ constexpr auto rint(T num) noexcept -> std::enable_if_t +template constexpr auto lrint(T num) noexcept -> std::enable_if_t, long> { return detail::lrint_impl(num); } -template +template constexpr auto llrint(T num) noexcept -> std::enable_if_t, long long> { return detail::lrint_impl(num); diff --git a/include/boost/decimal/detail/cmath/round.hpp b/include/boost/decimal/detail/cmath/round.hpp index 13e5b4711..008e34b81 100644 --- a/include/boost/decimal/detail/cmath/round.hpp +++ b/include/boost/decimal/detail/cmath/round.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -16,7 +17,7 @@ namespace boost { namespace decimal { -template +template constexpr auto round(T num) noexcept -> std::enable_if_t, T> { constexpr T zero {0, 0}; @@ -51,7 +52,7 @@ namespace detail { # pragma warning(disable: 4146) #endif -template +template constexpr auto int_round_impl(T num) noexcept -> std::enable_if_t, Int> { constexpr T zero {0, 0}; @@ -87,13 +88,13 @@ constexpr auto int_round_impl(T num) noexcept -> std::enable_if_t +template constexpr auto lround(T num) noexcept -> std::enable_if_t, long> { return detail::int_round_impl(num); } -template +template constexpr auto llround(T num) noexcept -> std::enable_if_t, long long> { return detail::int_round_impl(num); diff --git a/include/boost/decimal/detail/cmath/sin.hpp b/include/boost/decimal/detail/cmath/sin.hpp index 9da7dbd8b..909e60507 100644 --- a/include/boost/decimal/detail/cmath/sin.hpp +++ b/include/boost/decimal/detail/cmath/sin.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -16,9 +17,10 @@ #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto sin(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { T result { }; diff --git a/include/boost/decimal/detail/cmath/sinh.hpp b/include/boost/decimal/detail/cmath/sinh.hpp index 9e67f537c..90b20bc7d 100644 --- a/include/boost/decimal/detail/cmath/sinh.hpp +++ b/include/boost/decimal/detail/cmath/sinh.hpp @@ -11,11 +11,13 @@ #include // NOLINT(llvm-include-order) #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto sinh(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { const auto fpc = fpclassify(x); diff --git a/include/boost/decimal/detail/cmath/sqrt.hpp b/include/boost/decimal/detail/cmath/sqrt.hpp index 2531df1b8..49b8f84c8 100644 --- a/include/boost/decimal/detail/cmath/sqrt.hpp +++ b/include/boost/decimal/detail/cmath/sqrt.hpp @@ -7,14 +7,16 @@ #include #include +#include #include #include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto sqrt(T val) noexcept -> std::enable_if_t, T> { constexpr T zero {0, 0}; diff --git a/include/boost/decimal/detail/cmath/tan.hpp b/include/boost/decimal/detail/cmath/tan.hpp index a7414e4ce..0391fb2e4 100644 --- a/include/boost/decimal/detail/cmath/tan.hpp +++ b/include/boost/decimal/detail/cmath/tan.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -16,9 +17,10 @@ #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto tan(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { T result { }; diff --git a/include/boost/decimal/detail/cmath/tanh.hpp b/include/boost/decimal/detail/cmath/tanh.hpp index 7c75e96d9..3e82b89f0 100644 --- a/include/boost/decimal/detail/cmath/tanh.hpp +++ b/include/boost/decimal/detail/cmath/tanh.hpp @@ -11,11 +11,13 @@ #include // NOLINT(llvm-include-order) #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto tanh(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { const auto fpc = fpclassify(x); diff --git a/include/boost/decimal/detail/cmath/tgamma.hpp b/include/boost/decimal/detail/cmath/tgamma.hpp index 4fb738254..a0ede7f8d 100644 --- a/include/boost/decimal/detail/cmath/tgamma.hpp +++ b/include/boost/decimal/detail/cmath/tgamma.hpp @@ -11,11 +11,13 @@ #include // NOLINT(llvm-include-order) #include +#include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto tgamma(T x) noexcept -> std::enable_if_t, T> // NOLINT(misc-no-recursion) { T result { }; diff --git a/include/boost/decimal/detail/cmath/trunc.hpp b/include/boost/decimal/detail/cmath/trunc.hpp index 44f5f2683..2aac3f838 100644 --- a/include/boost/decimal/detail/cmath/trunc.hpp +++ b/include/boost/decimal/detail/cmath/trunc.hpp @@ -7,14 +7,16 @@ #include #include +#include #include #include #include #include -namespace boost { namespace decimal { +namespace boost { +namespace decimal { -template +template constexpr auto trunc(T val) noexcept -> std::enable_if_t, T> { return (val > 0) ? floor(val) : ceil(val); diff --git a/include/boost/decimal/detail/comparison.hpp b/include/boost/decimal/detail/comparison.hpp index bb3182a90..f9b619681 100644 --- a/include/boost/decimal/detail/comparison.hpp +++ b/include/boost/decimal/detail/comparison.hpp @@ -13,12 +13,13 @@ #include #include #include +#include #include namespace boost { namespace decimal { -template +template constexpr auto equal_parts_impl(T1 lhs_sig, std::int32_t lhs_exp, bool lhs_sign, T2 rhs_sig, std::int32_t rhs_exp, bool rhs_sign) noexcept -> bool { @@ -44,7 +45,7 @@ constexpr auto equal_parts_impl(T1 lhs_sig, std::int32_t lhs_exp, bool lhs_sign, new_lhs_sig == new_rhs_sig; } -template +template constexpr auto mixed_equality_impl(Decimal lhs, Integer rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_integral_v), bool> { @@ -68,7 +69,7 @@ constexpr auto mixed_equality_impl(Decimal lhs, Integer rhs) noexcept rhs_significand, INT32_C(0), rhs_isneg); } -template +template constexpr auto mixed_decimal_equality_impl(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool> @@ -87,7 +88,7 @@ constexpr auto mixed_decimal_equality_impl(Decimal1 lhs, Decimal2 rhs) noexcept return new_lhs == new_rhs; } -template +template constexpr auto operator==(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool> @@ -95,7 +96,7 @@ constexpr auto operator==(Decimal1 lhs, Decimal2 rhs) noexcept return mixed_decimal_equality_impl(lhs, rhs); } -template +template constexpr auto operator!=(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool> @@ -103,7 +104,7 @@ constexpr auto operator!=(Decimal1 lhs, Decimal2 rhs) noexcept return !(mixed_decimal_equality_impl(lhs, rhs)); } -template +template constexpr auto less_parts_impl(T1 lhs_sig, std::int32_t lhs_exp, bool lhs_sign, T2 rhs_sig, std::int32_t rhs_exp, bool rhs_sign) noexcept -> bool { @@ -163,7 +164,7 @@ constexpr auto less_parts_impl(T1 lhs_sig, std::int32_t lhs_exp, bool lhs_sign, } } -template +template constexpr auto less_impl(Decimal lhs, Integer rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_integral_v), bool> { @@ -209,7 +210,7 @@ constexpr auto less_impl(Decimal lhs, Integer rhs) noexcept rhs_significand, INT32_C(0), rhs_sign); } -template +template constexpr auto mixed_decimal_less_impl(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool> @@ -240,7 +241,7 @@ constexpr auto mixed_decimal_less_impl(Decimal1 lhs, Decimal2 rhs) noexcept rhs.full_significand(), rhs.biased_exponent(), rhs.isneg()); } -template +template constexpr auto operator<(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool> @@ -248,7 +249,7 @@ constexpr auto operator<(Decimal1 lhs, Decimal2 rhs) noexcept return mixed_decimal_less_impl(lhs, rhs); } -template +template constexpr auto operator<=(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool> @@ -261,7 +262,7 @@ constexpr auto operator<=(Decimal1 lhs, Decimal2 rhs) noexcept return !(rhs < lhs); } -template +template constexpr auto operator>(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool> @@ -269,7 +270,7 @@ constexpr auto operator>(Decimal1 lhs, Decimal2 rhs) noexcept return rhs < lhs; } -template +template constexpr auto operator>=(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), bool> @@ -284,7 +285,7 @@ constexpr auto operator>=(Decimal1 lhs, Decimal2 rhs) noexcept #ifdef BOOST_DECIMAL_HAS_SPACESHIP_OPERATOR -template +template constexpr auto operator<=>(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), std::partial_ordering> diff --git a/include/boost/decimal/detail/concepts.hpp b/include/boost/decimal/detail/concepts.hpp new file mode 100644 index 000000000..7572a7fe4 --- /dev/null +++ b/include/boost/decimal/detail/concepts.hpp @@ -0,0 +1,380 @@ +// Copyright 2022 - 2023 Matt Borland +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#ifndef BOOST_DECIMAL_DETAIL_CONCEPTS +#define BOOST_DECIMAL_DETAIL_CONCEPTS + +#if (__cplusplus >= 202002L || _MSVC_LANG >= 202002L) && !defined(BOOST_MATH_DISABLE_CONCEPTS) + +#if __has_include() + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost::decimal::concepts { + +namespace detail { + +template +struct op_valid_impl +{ + template + static constexpr auto test(int) -> decltype(std::declval()(std::declval(), std::declval()), + void(), std::true_type()); + + template + static constexpr auto test(...) -> std::false_type; + + using type = decltype(test(0)); +}; + +template +using op_valid_t = typename op_valid_impl::type; + +template +inline constexpr bool op_valid_v = op_valid_t::value; + +// Detector for class member functions +struct nonesuch +{ + nonesuch(const nonesuch&) = delete; + ~nonesuch() = delete; + void operator=(const nonesuch&) = delete; +}; + +template typename Op, typename... Args> +struct detector +{ + using value_t = std::false_type; + using type = Default; +}; + +template typename Op, typename... Args> +struct detector>, Op, Args...> +{ + using value_t = std::true_type; + using type = Op; +}; + +template typename Op, typename... Args> +using is_detected = typename detector::value_t; + +template typename Op, typename... Args> +using detected_t = typename detector::type; + +#define BOOST_DECIMAL_HAS_MEMBER_FUNCTION(member) \ +template \ +using has_##member##_t = decltype(std::declval().member()); \ + \ +template \ +inline constexpr bool has_##member##_v = is_detected::value; + +BOOST_DECIMAL_HAS_MEMBER_FUNCTION(begin) +BOOST_DECIMAL_HAS_MEMBER_FUNCTION(end) +BOOST_DECIMAL_HAS_MEMBER_FUNCTION(real) +BOOST_DECIMAL_HAS_MEMBER_FUNCTION(imag) + +} // Namespace detail + +template +concept integral = boost::decimal::detail::is_integral_v; + +template +concept signed_integral = integral && std::is_signed_v; + +template +concept unsigned_integral = integral && std::is_unsigned_v; + +template +concept real = boost::decimal::detail::is_floating_point_v; + +template +concept complex = std::is_same_v> + || std::is_same_v> + #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS + || std::is_same_v> + #endif + ; + +template +concept real_or_complex = real || complex; + +template +concept arithmetic = std::is_arithmetic_v; + +template +concept numerical = arithmetic || real_or_complex; + +template +concept signed_arithmetic = arithmetic && std::is_signed_v; + +template +concept unsigned_arithmetic = arithmetic && std::is_unsigned_v; + +template +concept arbitrary_unsigned_arithmetic_type = unsigned_arithmetic || + (detail::op_valid_v> && + detail::op_valid_v> && + detail::op_valid_v> && + detail::op_valid_v> && + detail::op_valid_v> && + detail::op_valid_v> && + detail::op_valid_v> && + detail::op_valid_v> && + detail::op_valid_v> && + detail::op_valid_v>); + +template +concept arbitrary_signed_arithmetic_type = signed_arithmetic || + (arbitrary_unsigned_arithmetic_type && + (detail::op_valid_v> || + std::numeric_limits::is_signed)); + +template +concept arbitrary_arithmetic_type = arbitrary_unsigned_arithmetic_type || + arbitrary_signed_arithmetic_type; + +template +concept arbitrary_unsigned_integer_type = arbitrary_unsigned_arithmetic_type && + std::numeric_limits::is_integer; + +template +concept arbitrary_signed_integer_type = arbitrary_signed_arithmetic_type && + std::numeric_limits::is_integer; + +template +concept arbitrary_integer_type = arbitrary_unsigned_integer_type || + arbitrary_signed_integer_type; + +template +concept arbitrary_real_type = arbitrary_arithmetic_type && + !std::numeric_limits::is_integer; + +template +concept arbitrary_complex_type = complex || + (detail::has_real_v && + detail::has_imag_v); + +template +concept arbitrary_real_or_complex_type = arbitrary_real_type || + arbitrary_complex_type; + +template +concept arbitrary_numerical_type = arbitrary_real_or_complex_type || + arbitrary_arithmetic_type; + +template +concept derived_from = std::is_base_of_v && + std::is_convertible_v; + +template +concept forward_iterator = derived_from::iterator_category, std::forward_iterator_tag>; + +template +concept bidirectional_iterator = derived_from::iterator_category, std::bidirectional_iterator_tag>; + +template +concept random_access_iterator = derived_from::iterator_category, std::random_access_iterator_tag>; + +template +concept output_iterator = derived_from::iterator_category, std::input_iterator_tag> && + derived_from::iterator_category, std::output_iterator_tag>; + +template +concept is_container = detail::has_begin_v && + detail::has_end_v; + +template +concept random_access_container = is_container && + boost::decimal::concepts::random_access_iterator; + +template +concept decimal_floating_point_type = boost::decimal::detail::is_decimal_floating_point_v; + +} // boost::decimal::concepts + +#define BOOST_DECIMAL_INTEGRAL boost::decimal::concepts::integral +#define BOOST_DECIMAL_SIGNED_INTEGRAL boost::decimal::concepts::signed_integral +#define BOOST_DECIMAL_UNSIGNED_INTEGRAL boost::decimal::concepts::unsigned_integral +#define BOOST_DECIMAL_REAL boost::decimal::concepts::real +#define BOOST_DECIMAL_COMPLEX boost::decimal::concepts::complex +#define BOOST_DECIMAL_REAL_OR_COMPLEX boost::decimal::concepts::real_or_complex +#define BOOST_DECIMAL_ARITHMETIC boost::decimal::concepts::arithmetic +#define BOOST_DECIMAL_NUMERICAL boost::decimal::concepts::numerical +#define BOOST_DECIMAL_SIGNED_ARITHMETIC boost::decimal::concepts::signed_arithmetic +#define BOOST_DECIMAL_UNSIGNED_ARITHMETIC boost::decimal::concepts::unsigned_arithmetic +#define BOOST_DECIMAL_ARBITRARY_UNSIGNED_ARITHMETIC boost::decimal::concepts::arbitrary_unsigned_arithmetic_type +#define BOOST_DECIMAL_ARBITRARY_SIGNED_ARITHMETIC boost::decimal::concepts::arbitrary_signed_arithmetic_type +#define BOOST_DECIMAL_ARBITRARY_ARITHMETIC boost::decimal::concepts::arbitrary_arithmetic_type +#define BOOST_DECIMAL_ARBITRARY_UNSIGNED_INTEGER boost::decimal::concepts::arbitrary_unsigned_integer_type +#define BOOST_DECIMAL_ARBITRARY_SIGNED_INTEGER boost::decimal::concepts::arbitrary_signed_integer_type +#define BOOST_DECIMAL_ARBITRARY_INTEGER boost::decimal::concepts::arbitrary_integer_type +#define BOOST_DECIMAL_ARBITRARY_REAL boost::decimal::concepts::arbitrary_real_type +#define BOOST_DECIMAL_ARBITRARY_COMPLEX boost::decimal::concepts::arbitrary_complex_type +#define BOOST_DECIMAL_ARBITRARY_REAL_OR_COMPLEX boost::decimal::concepts::arbitrary_real_or_complex_type +#define BOOST_DECIMAL_ARBITRARY_NUMERICAL boost::decimal::concepts::arbitrary_numerical_type +#define BOOST_DECIMAL_DECIMAL_FLOATING_TYPE boost::decimal::concepts::decimal_floating_point_type + +#define BOOST_DECIMAL_CONTAINER boost::decimal::concepts::is_container +#define BOOST_DECIMAL_RANDOM_ACCESS_CONTAINER boost::decimal::concepts::random_access_container + +#define BOOST_DECIMAL_FORWARD_ITER boost::decimal::concepts::forward_iterator +#define BOOST_DECIMAL_BIDIRECTIONAL_ITER boost::decimal::concepts::bidirectional_iterator +#define BOOST_DECIMAL_RANDOM_ACCESS_ITER boost::decimal::concepts::random_access_iterator +#define BOOST_DECIMAL_OUTPUT_ITER(I, T) boost::decimal::concepts::output_iterator +#define BOOST_DECIMAL_REQUIRES_ITER(X) requires X + +#define BOOST_DECIMAL_REQUIRES(X, T) requires X + +#ifdef BOOST_DECIMAL_EXEC_COMPATIBLE +#include + +namespace boost::decimal::concepts { + +template +concept execution_policy = std::is_execution_policy_v>; + +} // Namespace boost::decimal::concepts + +#define BOOST_DECIMAL_EXECUTION_POLICY boost::decimal::concepts::execution_policy + +#endif // Has + +#endif // Has +#endif // C++20 + +// If concepts are unavailable replace them with typename for compatibility + +#ifndef BOOST_DECIMAL_INTEGRAL +# define BOOST_DECIMAL_INTEGRAL typename +#endif + +#ifndef BOOST_DECIMAL_SIGNED_INTEGRAL +# define BOOST_DECIMAL_SIGNED_INTEGRAL typename +#endif + +#ifndef BOOST_DECIMAL_UNSIGNED_INTEGRAL +# define BOOST_DECIMAL_UNSIGNED_INTEGRAL typename +#endif + +#ifndef BOOST_DECIMAL_REAL +# define BOOST_DECIMAL_REAL typename +#endif + +#ifndef BOOST_DECIMAL_COMPLEX +# define BOOST_DECIMAL_COMPLEX typename +#endif + +#ifndef BOOST_DECIMAL_REAL_OR_COMPLEX +# define BOOST_DECIMAL_REAL_OR_COMPLEX typename +#endif + +#ifndef BOOST_DECIMAL_ARITHMETIC +# define BOOST_DECIMAL_ARITHMETIC typename +#endif + +#ifndef BOOST_DECIMAL_NUMERICAL +# define BOOST_DECIMAL_NUMERICAL typename +#endif + +#ifndef BOOST_DECIMAL_SIGNED_ARITHMETIC +# define BOOST_DECIMAL_SIGNED_ARITHMETIC typename +#endif + +#ifndef BOOST_DECIMAL_UNSIGNED_ARITHMETIC +# define BOOST_DECIMAL_UNSIGNED_ARITHMETIC typename +#endif + +#ifndef BOOST_DECIMAL_ARBITRARY_UNSIGNED_ARITHMETIC +# define BOOST_DECIMAL_ARBITRARY_UNSIGNED_ARITHMETIC typename +#endif + +#ifndef BOOST_DECIMAL_ARBITRARY_SIGNED_ARITHMETIC +# define BOOST_DECIMAL_ARBITRARY_SIGNED_ARITHMETIC typename +#endif + +#ifndef BOOST_DECIMAL_ARBITRARY_ARITHMETIC +# define BOOST_DECIMAL_ARBITRARY_ARITHMETIC typename +#endif + +#ifndef BOOST_DECIMAL_ARBITRARY_UNSIGNED_INTEGER +# define BOOST_DECIMAL_ARBITRARY_UNSIGNED_INTEGER typename +#endif + +#ifndef BOOST_DECIMAL_ARBITRARY_SIGNED_INTEGER +# define BOOST_DECIMAL_ARBITRARY_SIGNED_INTEGER typename +#endif + +#ifndef BOOST_DECIMAL_ARBITRARY_INTEGER +# define BOOST_DECIMAL_ARBITRARY_INTEGER typename +#endif + +#ifndef BOOST_DECIMAL_ARBITRARY_REAL +# define BOOST_DECIMAL_ARBITRARY_REAL typename +#endif + +#ifndef BOOST_DECIMAL_ARBITRARY_COMPLEX +# define BOOST_DECIMAL_ARBITRARY_COMPLEX typename +#endif + +#ifndef BOOST_DECIMAL_ARBITRARY_REAL_OR_COMPLEX +# define BOOST_DECIMAL_ARBITRARY_REAL_OR_COMPLEX typename +#endif + +#ifndef BOOST_DECIMAL_ARBITRARY_NUMERICAL +# define BOOST_DECIMAL_ARBITRARY_NUMERICAL typename +#endif + +#ifndef BOOST_DECIMAL_POLICY +# define BOOST_DECIMAL_POLICY typename +#endif + +#ifndef BOOST_DECIMAL_FORWARD_ITER +# define BOOST_DECIMAL_FORWARD_ITER typename +#endif + +#ifndef BOOST_DECIMAL_BIDIRECTIONAL_ITER +# define BOOST_DECIMAL_BIDIRECTIONAL_ITER typename +#endif + +#ifndef BOOST_DECIMAL_RANDOM_ACCESS_ITER +# define BOOST_DECIMAL_RANDOM_ACCESS_ITER typename +#endif + +#ifndef BOOST_DECIMAL_DECIMAL_FLOATING_TYPE +# define BOOST_DECIMAL_DECIMAL_FLOATING_TYPE typename +#endif + +#ifndef BOOST_DECIMAL_OUTPUT_ITER +# define BOOST_DECIMAL_OUTPUT_ITER(I, T) +#endif + +#ifndef BOOST_DECIMAL_REQUIRES_ITER +# define BOOST_DECIMAL_REQUIRES_ITER(X) +#endif + +#ifndef BOOST_DECIMAL_CONTAINER +# define BOOST_DECIMAL_CONTAINER typename +#endif + +#ifndef BOOST_DECIMAL_RANDOM_ACCESS_CONTAINER +# define BOOST_DECIMAL_RANDOM_ACCESS_CONTAINER typename +#endif + +#ifndef BOOST_DECIMAL_EXECUTION_POLICY +# define BOOST_DECIMAL_EXECUTION_POLICY typename +#endif + +#ifndef BOOST_DECIMAL_REQUIRES +# define BOOST_DECIMAL_REQUIRES(X, T) +#endif + +#endif //BOOST_DECIMAL_DETAIL_CONCEPTS diff --git a/include/boost/decimal/detail/io.hpp b/include/boost/decimal/detail/io.hpp index f571acc5e..5a014944d 100644 --- a/include/boost/decimal/detail/io.hpp +++ b/include/boost/decimal/detail/io.hpp @@ -27,7 +27,7 @@ namespace boost { namespace decimal { // 3.2.10 Formatted input: -template +template auto operator>>(std::basic_istream& is, DecimalType& d) -> std::enable_if_t, std::basic_istream&> { @@ -106,7 +106,7 @@ void print_buffer(char* buffer, std::size_t buffer_size, const char*, Integer si } // 3.2.11 Formatted output -template +template auto operator<<(std::basic_ostream& os, const DecimalType& d) -> std::enable_if_t, std::basic_ostream&> { diff --git a/include/boost/decimal/detail/mixed_decimal_arithmetic.hpp b/include/boost/decimal/detail/mixed_decimal_arithmetic.hpp index 9a0457ac6..8a8a76b0d 100644 --- a/include/boost/decimal/detail/mixed_decimal_arithmetic.hpp +++ b/include/boost/decimal/detail/mixed_decimal_arithmetic.hpp @@ -9,12 +9,13 @@ #include #include #include +#include #include namespace boost { namespace decimal { -template +template constexpr auto operator+(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), @@ -24,7 +25,7 @@ constexpr auto operator+(Decimal1 lhs, Decimal2 rhs) noexcept return static_cast(lhs) + static_cast(rhs); } -template +template constexpr auto operator-(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), @@ -34,7 +35,7 @@ constexpr auto operator-(Decimal1 lhs, Decimal2 rhs) noexcept return static_cast(lhs) - static_cast(rhs); } -template +template constexpr auto operator*(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), @@ -44,7 +45,7 @@ constexpr auto operator*(Decimal1 lhs, Decimal2 rhs) noexcept return static_cast(lhs) * static_cast(rhs); } -template +template constexpr auto operator/(Decimal1 lhs, Decimal2 rhs) noexcept -> std::enable_if_t<(detail::is_decimal_floating_point_v && detail::is_decimal_floating_point_v), diff --git a/include/boost/decimal/detail/to_decimal.hpp b/include/boost/decimal/detail/to_decimal.hpp index 4ad7d2366..98ec76dec 100644 --- a/include/boost/decimal/detail/to_decimal.hpp +++ b/include/boost/decimal/detail/to_decimal.hpp @@ -11,13 +11,14 @@ #include #include #include +#include namespace boost { namespace decimal { #ifndef BOOST_DECIMAL_NO_CXX17_IF_CONSTEXPR -template +template constexpr auto to_decimal(Decimal val) noexcept -> TargetType { if (isinf(val)) @@ -48,7 +49,7 @@ constexpr auto to_decimal(Decimal val) noexcept -> TargetType #else -template +template constexpr auto to_decimal(Decimal val) noexcept -> TargetType { if (isinf(val)) diff --git a/include/boost/decimal/detail/to_float.hpp b/include/boost/decimal/detail/to_float.hpp index 9a6274d35..f7e1f5eaa 100644 --- a/include/boost/decimal/detail/to_float.hpp +++ b/include/boost/decimal/detail/to_float.hpp @@ -14,11 +14,12 @@ #include #include #include +#include namespace boost { namespace decimal { -template +template BOOST_DECIMAL_CXX20_CONSTEXPR auto to_float(Decimal val) noexcept -> TargetType { bool success {}; diff --git a/include/boost/decimal/detail/to_integral.hpp b/include/boost/decimal/detail/to_integral.hpp index 49448f06e..6a7ac90cc 100644 --- a/include/boost/decimal/detail/to_integral.hpp +++ b/include/boost/decimal/detail/to_integral.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace boost { namespace decimal { @@ -25,7 +26,7 @@ namespace decimal { // Attempts conversion to integral type: // If this is nan sets errno to EINVAL and returns 0 // If this is not representable sets errno to ERANGE and returns 0 -template +template constexpr auto to_integral(Decimal val) noexcept -> TargetType { using Conversion_Type = std::conditional_t::is_signed, std::int64_t, std::uint64_t>; @@ -63,7 +64,7 @@ constexpr auto to_integral(Decimal val) noexcept -> TargetType return static_cast(result); } -template +template constexpr auto to_integral_128(Decimal val) noexcept -> TargetType { constexpr Decimal max_target_type { (std::numeric_limits::max)() }; diff --git a/test/Jamfile b/test/Jamfile index 40cd80115..44e596af4 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -17,6 +17,7 @@ project : requirements [ requires cxx14_decltype_auto cxx14_generic_lambdas cxx14_return_type_deduction cxx14_variable_templates cxx14_constexpr ] ; +compile-fail concepts_test.cpp ; run ibm_abs.cpp ; run ibm_add.cpp ; run quick.cpp ; diff --git a/test/concepts_test.cpp b/test/concepts_test.cpp new file mode 100644 index 000000000..bac779ba6 --- /dev/null +++ b/test/concepts_test.cpp @@ -0,0 +1,25 @@ +// Copyright 2023 Matt Borland +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include + +template +void test() +{ + T res = T(1.0) + 1.0; + BOOST_TEST_EQ(res, T(2.0)); + BOOST_TEST(boost::decimal::abs(1.0)); +} + + +int main() +{ + test(); + //test(); + //test(); + + return boost::report_errors(); +} +