// Copyright 2023 Matt Borland // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt #ifndef BOOST_DECIMAL_DETAIL_TYPE_TRAITS #define BOOST_DECIMAL_DETAIL_TYPE_TRAITS // Extends the current type traits to include our types and __int128s #include #include #include #include #include "int128.hpp" #ifndef BOOST_DECIMAL_BUILD_MODULE #include #endif namespace boost { namespace decimal { namespace detail { template struct is_signed { static constexpr bool value = std::is_signed::value; }; template <> struct is_signed { static constexpr bool value = true; }; template <> struct is_signed { static constexpr bool value = false; }; #ifdef BOOST_DECIMAL_HAS_INT128 template <> struct is_signed { static constexpr bool value = true; }; template <> struct is_signed { static constexpr bool value = false;}; #endif template <> struct is_signed { static constexpr bool value = false; }; template constexpr bool is_signed::value; template constexpr bool is_signed_v = is_signed::value; template constexpr bool is_unsigned_v = !is_signed_v; template struct make_unsigned { using type = std::make_unsigned_t; }; template <> struct make_unsigned { using type = std::uint8_t; }; template <> struct make_unsigned { using type = boost::int128::uint128_t; }; template <> struct make_unsigned { using type = boost::int128::uint128_t; }; #ifdef BOOST_DECIMAL_HAS_INT128 template <> struct make_unsigned { using type = builtin_uint128_t; }; template <> struct make_unsigned { using type = builtin_uint128_t; }; #endif template using make_unsigned_t = typename make_unsigned::type; template struct make_signed { using type = std::make_signed_t; }; template <> struct make_signed { using type = boost::int128::int128_t; }; template <> struct make_signed { using type = boost::int128::int128_t; }; #ifdef BOOST_DECIMAL_HAS_INT128 template <> struct make_signed { using type = builtin_int128_t; }; template <> struct make_signed { using type = builtin_int128_t; }; #endif template using make_signed_t = typename make_signed::type; template struct is_integral { static constexpr bool value = std::is_integral::value;}; template <> struct is_integral { static constexpr bool value = true; }; template <> struct is_integral { static constexpr bool value = true; }; #ifdef BOOST_DECIMAL_HAS_INT128 template <> struct is_integral { static constexpr bool value = true; }; template <> struct is_integral { static constexpr bool value = true; }; #endif template <> struct is_integral { static constexpr bool value = true; }; template constexpr bool is_integral::value; template constexpr bool is_integral_v = is_integral::value; template struct is_floating_point { static constexpr bool value = std::is_floating_point::value; }; #if defined(BOOST_DECIMAL_HAS_FLOAT128) && !defined(BOOST_DECIMAL_LDBL_IS_FLOAT128) template <> struct is_floating_point<__float128> { static constexpr bool value = true; }; #endif template constexpr bool is_floating_point::value; template constexpr bool is_floating_point_v = is_floating_point::value; template struct is_decimal_floating_point { static constexpr bool value = false; }; template <> struct is_decimal_floating_point { static constexpr bool value = true; }; template <> struct is_decimal_floating_point { static constexpr bool value = true; }; template <> struct is_decimal_floating_point { static constexpr bool value = true; }; template <> struct is_decimal_floating_point { static constexpr bool value = true; }; template <> struct is_decimal_floating_point { static constexpr bool value = true; }; template <> struct is_decimal_floating_point { static constexpr bool value = true; }; template constexpr bool is_decimal_floating_point::value; template constexpr bool is_decimal_floating_point_v = is_decimal_floating_point::value; template struct is_decimal_floating_point_components { static constexpr bool value = false; }; template <> struct is_decimal_floating_point_components { static constexpr bool value = true; }; template <> struct is_decimal_floating_point_components { static constexpr bool value = true; }; template <> struct is_decimal_floating_point_components { static constexpr bool value = true; }; template constexpr bool is_decimal_floating_point_components::value; template constexpr bool is_decimal_floating_point_components_v = is_decimal_floating_point_components::value; template struct is_ieee_type { static constexpr bool value = false; }; template <> struct is_ieee_type { static constexpr bool value = true; }; template <> struct is_ieee_type { static constexpr bool value = true; }; template <> struct is_ieee_type { static constexpr bool value = true; }; template <> struct is_ieee_type { static constexpr bool value = false; }; template <> struct is_ieee_type { static constexpr bool value = false; }; template <> struct is_ieee_type { static constexpr bool value = false; }; template constexpr bool is_ieee_type_v = is_ieee_type::value; template constexpr bool is_fast_type_v = !is_ieee_type_v; template struct conjunction : std::true_type {}; template struct conjunction : B1 {}; template struct conjunction : std::conditional_t(B1::value), conjunction, B1> {}; template BOOST_DECIMAL_INLINE_CONSTEXPR_VARIABLE bool conjunction_v = conjunction::value; } // namespace detail } // namespace decimal } // namespace boost #endif