diff --git a/include/fmt/base.h b/include/fmt/base.h index beaa835c..6102044f 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -396,19 +396,19 @@ constexpr auto is_constant_evaluated(bool default_value = false) noexcept #elif defined(__SIZEOF_INT128__) && !defined(__NVCC__) && \ !(FMT_CLANG_VERSION && FMT_MSC_VERSION) # define FMT_USE_INT128 1 -using int128_opt = __int128_t; // An optional native 128-bit integer. -using uint128_opt = __uint128_t; -inline auto map(int128_opt x) -> int128_opt { return x; } -inline auto map(uint128_opt x) -> uint128_opt { return x; } +using native_int128 = __int128_t; +using native_uint128 = __uint128_t; +inline auto map(native_int128 x) -> native_int128 { return x; } +inline auto map(native_uint128 x) -> native_uint128 { return x; } #else # define FMT_USE_INT128 0 #endif #if !FMT_USE_INT128 -enum class int128_opt {}; -enum class uint128_opt {}; +enum class native_int128 {}; // A fallback to reduce conditional compilation. +enum class native_uint128 {}; // Reduce template instantiations. -inline auto map(int128_opt) -> monostate { return {}; } -inline auto map(uint128_opt) -> monostate { return {}; } +inline auto map(native_int128) -> monostate { return {}; } +inline auto map(native_uint128) -> monostate { return {}; } #endif // Casts a nonnegative integer to unsigned. @@ -985,8 +985,8 @@ FMT_TYPE_CONSTANT(int, int_type); FMT_TYPE_CONSTANT(unsigned, uint_type); FMT_TYPE_CONSTANT(long long, long_long_type); FMT_TYPE_CONSTANT(ullong, ulong_long_type); -FMT_TYPE_CONSTANT(int128_opt, int128_type); -FMT_TYPE_CONSTANT(uint128_opt, uint128_type); +FMT_TYPE_CONSTANT(native_int128, int128_type); +FMT_TYPE_CONSTANT(native_uint128, uint128_type); FMT_TYPE_CONSTANT(bool, bool_type); FMT_TYPE_CONSTANT(Char, char_type); FMT_TYPE_CONSTANT(float, float_type); @@ -1156,8 +1156,8 @@ template struct type_mapper { static auto map(unsigned long) -> ulong_type; static auto map(long long) -> long long; static auto map(ullong) -> ullong; - static auto map(int128_opt) -> int128_opt; - static auto map(uint128_opt) -> uint128_opt; + static auto map(native_int128) -> native_int128; + static auto map(native_uint128) -> native_uint128; static auto map(bool) -> bool; template ::value)> @@ -2080,8 +2080,8 @@ template class value { unsigned uint_value; long long long_long_value; ullong ulong_long_value; - int128_opt int128_value; - uint128_opt uint128_value; + native_int128 int128_value; + native_uint128 uint128_value; bool bool_value; char_type char_value; float float_value; @@ -2105,8 +2105,8 @@ template class value { : value(ulong_type(x)) {} constexpr FMT_INLINE value(long long x FMT_BUILTIN) : long_long_value(x) {} constexpr FMT_INLINE value(ullong x FMT_BUILTIN) : ulong_long_value(x) {} - FMT_INLINE value(int128_opt x FMT_BUILTIN) : int128_value(x) {} - FMT_INLINE value(uint128_opt x FMT_BUILTIN) : uint128_value(x) {} + FMT_INLINE value(native_int128 x FMT_BUILTIN) : int128_value(x) {} + FMT_INLINE value(native_uint128 x FMT_BUILTIN) : uint128_value(x) {} constexpr FMT_INLINE value(bool x FMT_BUILTIN) : bool_value(x) {} template ::value)> diff --git a/include/fmt/format.h b/include/fmt/format.h index 2899685e..b04708a4 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -47,9 +47,9 @@ #endif #ifndef FMT_MODULE +# include // uint32_t # include // malloc, free # include // memcpy -# include // uint32_t # include // std::signbit # include // std::byte @@ -403,7 +403,8 @@ class uint128_fallback { } }; -using uint128_t = conditional_t; +using uint128_t = + conditional_t; #ifdef UINTPTR_MAX using uintptr_t = ::uintptr_t; @@ -420,8 +421,8 @@ template constexpr auto num_bits() -> int { return std::numeric_limits::digits; } // std::numeric_limits::digits may return 0 for 128-bit ints. -template <> constexpr auto num_bits() -> int { return 128; } -template <> constexpr auto num_bits() -> int { return 128; } +template <> constexpr auto num_bits() -> int { return 128; } +template <> constexpr auto num_bits() -> int { return 128; } template <> constexpr auto num_bits() -> int { return 128; } // A heterogeneous bit_cast used for converting 96-bit long double to uint128_t @@ -738,13 +739,13 @@ FMT_CONSTEXPR inline auto display_width_of(uint32_t cp) noexcept -> size_t { } template struct is_integral : std::is_integral {}; -template <> struct is_integral : std::true_type {}; +template <> struct is_integral : std::true_type {}; template <> struct is_integral : std::true_type {}; template using is_signed = std::integral_constant::is_signed || - std::is_same::value>; + std::is_same::value>; template using is_integer = @@ -1125,7 +1126,7 @@ template FMT_CONSTEXPR auto count_digits_fallback(T n) -> int { } } #if FMT_USE_INT128 -FMT_CONSTEXPR inline auto count_digits(uint128_opt n) -> int { +FMT_CONSTEXPR inline auto count_digits(native_uint128 n) -> int { return count_digits_fallback(n); } #endif @@ -1213,7 +1214,9 @@ FMT_CONSTEXPR20 inline auto count_digits(uint32_t n) -> int { template constexpr auto digits10() noexcept -> int { return std::numeric_limits::digits10; } -template <> constexpr auto digits10() noexcept -> int { return 38; } +template <> constexpr auto digits10() noexcept -> int { + return 38; +} template <> constexpr auto digits10() noexcept -> int { return 38; } template struct thousands_sep_result { @@ -1471,7 +1474,7 @@ template class to_utf8 { // Computes 128-bit result of multiplication of two 64-bit unsigned integers. FMT_INLINE auto umul128(uint64_t x, uint64_t y) noexcept -> uint128_fallback { #if FMT_USE_INT128 - auto p = static_cast(x) * static_cast(y); + auto p = static_cast(x) * static_cast(y); return {static_cast(p >> 64), static_cast(p)}; #elif defined(_MSC_VER) && defined(_M_AMD64) auto hi = uint64_t(); @@ -1514,7 +1517,7 @@ inline auto floor_log2_pow10(int e) noexcept -> int { // Computes upper 64 bits of multiplication of two 64-bit unsigned integers. inline auto umul128_upper64(uint64_t x, uint64_t y) noexcept -> uint64_t { #if FMT_USE_INT128 - auto p = static_cast(x) * static_cast(y); + auto p = static_cast(x) * static_cast(y); return static_cast(p >> 64); #elif defined(_MSC_VER) && defined(_M_AMD64) return __umulh(x, y);