diff --git a/include/fmt/base.h b/include/fmt/base.h index 02840efd..bfd869ac 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -320,6 +320,8 @@ using underlying_t = typename std::underlying_type::type; template using decay_t = typename std::decay::type; using nullptr_t = decltype(nullptr); +using ullong = unsigned long long; + #if (FMT_GCC_VERSION && FMT_GCC_VERSION < 500) || FMT_MSC_VERSION // A workaround for gcc 4.9 & MSVC v141 to make void_t work in a SFINAE context. template struct void_t_impl { @@ -1014,7 +1016,7 @@ struct type_constant : std::integral_constant {}; FMT_TYPE_CONSTANT(int, int_type); FMT_TYPE_CONSTANT(unsigned, uint_type); FMT_TYPE_CONSTANT(long long, long_long_type); -FMT_TYPE_CONSTANT(unsigned long long, ulong_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(bool, bool_type); @@ -1131,7 +1133,7 @@ FMT_CONSTEXPR void init_static_named_arg(named_arg_info* named_args, // either to int or to long long depending on its size. enum { long_short = sizeof(long) == sizeof(int) && FMT_BUILTIN_TYPES }; using long_type = conditional_t; -using ulong_type = conditional_t; +using ulong_type = conditional_t; template using format_as_result = @@ -1185,7 +1187,7 @@ template struct type_mapper { static auto map(long) -> long_type; static auto map(unsigned long) -> ulong_type; static auto map(long long) -> long long; - static auto map(unsigned long long) -> unsigned long long; + static auto map(ullong) -> ullong; static auto map(int128_opt) -> int128_opt; static auto map(uint128_opt) -> uint128_opt; static auto map(bool) -> bool; @@ -1193,8 +1195,7 @@ template struct type_mapper { template static auto map(bitint) -> conditional_t; template - static auto map(ubitint) - -> conditional_t; + static auto map(ubitint) -> conditional_t; template ::value)> static auto map(T) -> conditional_t< @@ -2178,7 +2179,7 @@ template class value { int int_value; unsigned uint_value; long long long_long_value; - unsigned long long ulong_long_value; + ullong ulong_long_value; int128_opt int128_value; uint128_opt uint128_value; bool bool_value; @@ -2203,8 +2204,7 @@ template class value { constexpr FMT_INLINE value(unsigned long x FMT_BUILTIN) : value(ulong_type(x)) {} constexpr FMT_INLINE value(long long x FMT_BUILTIN) : long_long_value(x) {} - constexpr FMT_INLINE value(unsigned long long x FMT_BUILTIN) - : ulong_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) {} constexpr FMT_INLINE value(bool x FMT_BUILTIN) : bool_value(x) {} @@ -2324,8 +2324,8 @@ template class value { enum { packed_arg_bits = 4 }; // Maximum number of arguments with packed types. enum { max_packed_args = 62 / packed_arg_bits }; -enum : unsigned long long { is_unpacked_bit = 1ULL << 63 }; -enum : unsigned long long { has_named_args_bit = 1ULL << 62 }; +enum : ullong { is_unpacked_bit = 1ULL << 63 }; +enum : ullong { has_named_args_bit = 1ULL << 62 }; template struct is_output_iterator : std::false_type {}; @@ -2338,18 +2338,16 @@ struct is_output_iterator< enable_if_t&>()++), T>::value>> : std::true_type {}; -template constexpr auto encode_types() -> unsigned long long { - return 0; -} +template constexpr auto encode_types() -> ullong { return 0; } template -constexpr auto encode_types() -> unsigned long long { +constexpr auto encode_types() -> ullong { return static_cast(stored_type_constant::value) | (encode_types() << packed_arg_bits); } template -constexpr auto make_descriptor() -> unsigned long long { +constexpr auto make_descriptor() -> ullong { return NUM_ARGS <= max_packed_args ? encode_types() : is_unpacked_bit | NUM_ARGS; } @@ -2358,8 +2356,7 @@ template using arg_t = conditional_t, basic_format_arg>; -template +template struct named_arg_store { // args_[0].named_args points to named_args to avoid bloating format_args. arg_t args[1u + NUM_ARGS]; @@ -2391,8 +2388,7 @@ struct named_arg_store { // An array of references to arguments. It can be implicitly converted to // `basic_format_args` for passing into type-erased formatting functions // such as `vformat`. It is a plain struct to reduce binary size in debug mode. -template +template struct format_arg_store { // +1 to workaround a bug in gcc 7.5 that causes duplicated-branches warning. using type = @@ -2585,7 +2581,7 @@ template class basic_format_args { // If the number of arguments is less or equal to max_packed_args then // argument types are passed in the descriptor. This reduces binary code size // per formatting function call. - unsigned long long desc_; + ullong desc_; union { // If is_packed() returns true then argument values are stored in values_; // otherwise they are stored in args_. This is done to improve cache @@ -2609,7 +2605,7 @@ template class basic_format_args { return static_cast((desc_ >> shift) & mask); } - template + template using store = detail::format_arg_store; @@ -2619,14 +2615,14 @@ template class basic_format_args { constexpr basic_format_args() : desc_(0), args_(nullptr) {} /// Constructs a `basic_format_args` object from `format_arg_store`. - template constexpr FMT_ALWAYS_INLINE basic_format_args( const store& s) : desc_(DESC | (NUM_NAMED_ARGS != 0 ? +detail::has_named_args_bit : 0)), values_(s.args) {} - template detail::max_packed_args)> constexpr basic_format_args(const store& s) : desc_(DESC | (NUM_NAMED_ARGS != 0 ? +detail::has_named_args_bit : 0)), @@ -2670,8 +2666,7 @@ template class basic_format_args { } auto max_size() const -> int { - unsigned long long max_packed = detail::max_packed_args; - return static_cast(is_packed() ? max_packed + return static_cast(is_packed() ? ullong(detail::max_packed_args) : desc_ & ~detail::is_unpacked_bit); } }; @@ -2816,7 +2811,7 @@ struct formatter(), - unsigned long long DESC = detail::make_descriptor()> + ullong DESC = detail::make_descriptor()> constexpr FMT_ALWAYS_INLINE auto make_format_args(T&... args) -> detail::format_arg_store { // Suppress warnings for pathological types convertible to detail::value. diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 9fbeeed6..fe86ef8d 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -544,8 +544,7 @@ namespace detail { // https://johnnylee-sde.github.io/Fast-unsigned-integer-to-time-string/. inline void write_digit2_separated(char* buf, unsigned a, unsigned b, unsigned c, char sep) { - unsigned long long digits = - a | (b << 24) | (static_cast(c) << 48); + ullong digits = a | (b << 24) | (static_cast(c) << 48); // Convert each value to BCD. // We have x = a * 10 + b and we want to convert it to BCD y = a * 16 + b. // The difference is @@ -559,7 +558,7 @@ inline void write_digit2_separated(char* buf, unsigned a, unsigned b, // Put low nibbles to high bytes and high nibbles to low bytes. digits = ((digits & 0x00f00000f00000f0) >> 4) | ((digits & 0x000f00000f00000f) << 8); - auto usep = static_cast(sep); + auto usep = static_cast(sep); // Add ASCII '0' to each digit byte and insert separators. digits |= 0x3030003030003030 | (usep << 16) | (usep << 40); diff --git a/include/fmt/format.h b/include/fmt/format.h index 14d8baf5..6bff3e0a 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -394,11 +394,11 @@ class uint128_fallback { return *this; } #if FMT_HAS_BUILTIN(__builtin_addcll) && !defined(__ibmxl__) - unsigned long long carry; + ullong carry; lo_ = __builtin_addcll(lo_, n, 0, &carry); hi_ += carry; #elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) && !defined(__ibmxl__) - unsigned long long result; + ullong result; auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result); lo_ = result; hi_ += carry; @@ -1645,7 +1645,7 @@ template struct basic_fp { } }; -using fp = basic_fp; +using fp = basic_fp; // Normalizes the value converted from double and multiplied by (1 << SHIFT). template @@ -3733,12 +3733,12 @@ template struct arg_formatter { struct dynamic_spec_getter { template ::value)> - FMT_CONSTEXPR auto operator()(T value) -> unsigned long long { - return is_negative(value) ? ~0ull : static_cast(value); + FMT_CONSTEXPR auto operator()(T value) -> ullong { + return is_negative(value) ? ~0ull : static_cast(value); } template ::value)> - FMT_CONSTEXPR auto operator()(T) -> unsigned long long { + FMT_CONSTEXPR auto operator()(T) -> ullong { report_error("width/precision is not integer"); return 0; } @@ -3752,7 +3752,7 @@ FMT_CONSTEXPR void handle_dynamic_spec( auto arg = kind == arg_id_kind::index ? ctx.arg(ref.index) : ctx.arg(ref.name); if (!arg) report_error("argument not found"); - unsigned long long result = arg.visit(dynamic_spec_getter()); + ullong result = arg.visit(dynamic_spec_getter()); if (result > to_unsigned(max_value())) report_error("width/precision is out of range"); value = static_cast(result); @@ -3982,8 +3982,7 @@ class formatter, Char> template struct formatter, Char> : formatter {}; template -struct formatter, Char> - : formatter {}; +struct formatter, Char> : formatter {}; template struct formatter @@ -4210,7 +4209,7 @@ class format_int { private: // Buffer should be large enough to hold all digits (digits10 + 1), // a sign and a null character. - enum { buffer_size = std::numeric_limits::digits10 + 3 }; + enum { buffer_size = std::numeric_limits::digits10 + 3 }; mutable char buffer_[buffer_size]; char* str_; @@ -4240,7 +4239,7 @@ class format_int { : str_(format_unsigned(value)) {} FMT_CONSTEXPR20 explicit format_int(unsigned long value) : str_(format_unsigned(value)) {} - FMT_CONSTEXPR20 explicit format_int(unsigned long long value) + FMT_CONSTEXPR20 explicit format_int(ullong value) : str_(format_unsigned(value)) {} /// Returns the number of characters written to the output buffer.