Skip to content

Commit 9237a45

Browse files
committed
Add an alias for unsigned long long
1 parent ed409c5 commit 9237a45

File tree

3 files changed

+33
-40
lines changed

3 files changed

+33
-40
lines changed

include/fmt/base.h

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ using underlying_t = typename std::underlying_type<T>::type;
320320
template <typename T> using decay_t = typename std::decay<T>::type;
321321
using nullptr_t = decltype(nullptr);
322322

323+
using ullong = unsigned long long;
324+
323325
#if (FMT_GCC_VERSION && FMT_GCC_VERSION < 500) || FMT_MSC_VERSION
324326
// A workaround for gcc 4.9 & MSVC v141 to make void_t work in a SFINAE context.
325327
template <typename...> struct void_t_impl {
@@ -1014,7 +1016,7 @@ struct type_constant : std::integral_constant<type, type::custom_type> {};
10141016
FMT_TYPE_CONSTANT(int, int_type);
10151017
FMT_TYPE_CONSTANT(unsigned, uint_type);
10161018
FMT_TYPE_CONSTANT(long long, long_long_type);
1017-
FMT_TYPE_CONSTANT(unsigned long long, ulong_long_type);
1019+
FMT_TYPE_CONSTANT(ullong, ulong_long_type);
10181020
FMT_TYPE_CONSTANT(int128_opt, int128_type);
10191021
FMT_TYPE_CONSTANT(uint128_opt, uint128_type);
10201022
FMT_TYPE_CONSTANT(bool, bool_type);
@@ -1131,7 +1133,7 @@ FMT_CONSTEXPR void init_static_named_arg(named_arg_info<Char>* named_args,
11311133
// either to int or to long long depending on its size.
11321134
enum { long_short = sizeof(long) == sizeof(int) && FMT_BUILTIN_TYPES };
11331135
using long_type = conditional_t<long_short, int, long long>;
1134-
using ulong_type = conditional_t<long_short, unsigned, unsigned long long>;
1136+
using ulong_type = conditional_t<long_short, unsigned, ullong>;
11351137

11361138
template <typename T>
11371139
using format_as_result =
@@ -1185,16 +1187,15 @@ template <typename Char> struct type_mapper {
11851187
static auto map(long) -> long_type;
11861188
static auto map(unsigned long) -> ulong_type;
11871189
static auto map(long long) -> long long;
1188-
static auto map(unsigned long long) -> unsigned long long;
1190+
static auto map(ullong) -> ullong;
11891191
static auto map(int128_opt) -> int128_opt;
11901192
static auto map(uint128_opt) -> uint128_opt;
11911193
static auto map(bool) -> bool;
11921194

11931195
template <int N>
11941196
static auto map(bitint<N>) -> conditional_t<N <= 64, long long, void>;
11951197
template <int N>
1196-
static auto map(ubitint<N>)
1197-
-> conditional_t<N <= 64, unsigned long long, void>;
1198+
static auto map(ubitint<N>) -> conditional_t<N <= 64, ullong, void>;
11981199

11991200
template <typename T, FMT_ENABLE_IF(is_code_unit<T>::value)>
12001201
static auto map(T) -> conditional_t<
@@ -2178,7 +2179,7 @@ template <typename Context> class value {
21782179
int int_value;
21792180
unsigned uint_value;
21802181
long long long_long_value;
2181-
unsigned long long ulong_long_value;
2182+
ullong ulong_long_value;
21822183
int128_opt int128_value;
21832184
uint128_opt uint128_value;
21842185
bool bool_value;
@@ -2203,8 +2204,7 @@ template <typename Context> class value {
22032204
constexpr FMT_INLINE value(unsigned long x FMT_BUILTIN)
22042205
: value(ulong_type(x)) {}
22052206
constexpr FMT_INLINE value(long long x FMT_BUILTIN) : long_long_value(x) {}
2206-
constexpr FMT_INLINE value(unsigned long long x FMT_BUILTIN)
2207-
: ulong_long_value(x) {}
2207+
constexpr FMT_INLINE value(ullong x FMT_BUILTIN) : ulong_long_value(x) {}
22082208
FMT_INLINE value(int128_opt x FMT_BUILTIN) : int128_value(x) {}
22092209
FMT_INLINE value(uint128_opt x FMT_BUILTIN) : uint128_value(x) {}
22102210
constexpr FMT_INLINE value(bool x FMT_BUILTIN) : bool_value(x) {}
@@ -2324,8 +2324,8 @@ template <typename Context> class value {
23242324
enum { packed_arg_bits = 4 };
23252325
// Maximum number of arguments with packed types.
23262326
enum { max_packed_args = 62 / packed_arg_bits };
2327-
enum : unsigned long long { is_unpacked_bit = 1ULL << 63 };
2328-
enum : unsigned long long { has_named_args_bit = 1ULL << 62 };
2327+
enum : ullong { is_unpacked_bit = 1ULL << 63 };
2328+
enum : ullong { has_named_args_bit = 1ULL << 62 };
23292329

23302330
template <typename It, typename T, typename Enable = void>
23312331
struct is_output_iterator : std::false_type {};
@@ -2338,18 +2338,16 @@ struct is_output_iterator<
23382338
enable_if_t<std::is_assignable<decltype(*std::declval<decay_t<It>&>()++),
23392339
T>::value>> : std::true_type {};
23402340

2341-
template <typename> constexpr auto encode_types() -> unsigned long long {
2342-
return 0;
2343-
}
2341+
template <typename> constexpr auto encode_types() -> ullong { return 0; }
23442342

23452343
template <typename Context, typename First, typename... T>
2346-
constexpr auto encode_types() -> unsigned long long {
2344+
constexpr auto encode_types() -> ullong {
23472345
return static_cast<unsigned>(stored_type_constant<First, Context>::value) |
23482346
(encode_types<Context, T...>() << packed_arg_bits);
23492347
}
23502348

23512349
template <typename Context, typename... T, size_t NUM_ARGS = sizeof...(T)>
2352-
constexpr auto make_descriptor() -> unsigned long long {
2350+
constexpr auto make_descriptor() -> ullong {
23532351
return NUM_ARGS <= max_packed_args ? encode_types<Context, T...>()
23542352
: is_unpacked_bit | NUM_ARGS;
23552353
}
@@ -2358,8 +2356,7 @@ template <typename Context, int NUM_ARGS>
23582356
using arg_t = conditional_t<NUM_ARGS <= max_packed_args, value<Context>,
23592357
basic_format_arg<Context>>;
23602358

2361-
template <typename Context, int NUM_ARGS, int NUM_NAMED_ARGS,
2362-
unsigned long long DESC>
2359+
template <typename Context, int NUM_ARGS, int NUM_NAMED_ARGS, ullong DESC>
23632360
struct named_arg_store {
23642361
// args_[0].named_args points to named_args to avoid bloating format_args.
23652362
arg_t<Context, NUM_ARGS> args[1u + NUM_ARGS];
@@ -2391,8 +2388,7 @@ struct named_arg_store {
23912388
// An array of references to arguments. It can be implicitly converted to
23922389
// `basic_format_args` for passing into type-erased formatting functions
23932390
// such as `vformat`. It is a plain struct to reduce binary size in debug mode.
2394-
template <typename Context, int NUM_ARGS, int NUM_NAMED_ARGS,
2395-
unsigned long long DESC>
2391+
template <typename Context, int NUM_ARGS, int NUM_NAMED_ARGS, ullong DESC>
23962392
struct format_arg_store {
23972393
// +1 to workaround a bug in gcc 7.5 that causes duplicated-branches warning.
23982394
using type =
@@ -2585,7 +2581,7 @@ template <typename Context> class basic_format_args {
25852581
// If the number of arguments is less or equal to max_packed_args then
25862582
// argument types are passed in the descriptor. This reduces binary code size
25872583
// per formatting function call.
2588-
unsigned long long desc_;
2584+
ullong desc_;
25892585
union {
25902586
// If is_packed() returns true then argument values are stored in values_;
25912587
// otherwise they are stored in args_. This is done to improve cache
@@ -2609,7 +2605,7 @@ template <typename Context> class basic_format_args {
26092605
return static_cast<detail::type>((desc_ >> shift) & mask);
26102606
}
26112607

2612-
template <int NUM_ARGS, int NUM_NAMED_ARGS, unsigned long long DESC>
2608+
template <int NUM_ARGS, int NUM_NAMED_ARGS, ullong DESC>
26132609
using store =
26142610
detail::format_arg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC>;
26152611

@@ -2619,14 +2615,14 @@ template <typename Context> class basic_format_args {
26192615
constexpr basic_format_args() : desc_(0), args_(nullptr) {}
26202616

26212617
/// Constructs a `basic_format_args` object from `format_arg_store`.
2622-
template <int NUM_ARGS, int NUM_NAMED_ARGS, unsigned long long DESC,
2618+
template <int NUM_ARGS, int NUM_NAMED_ARGS, ullong DESC,
26232619
FMT_ENABLE_IF(NUM_ARGS <= detail::max_packed_args)>
26242620
constexpr FMT_ALWAYS_INLINE basic_format_args(
26252621
const store<NUM_ARGS, NUM_NAMED_ARGS, DESC>& s)
26262622
: desc_(DESC | (NUM_NAMED_ARGS != 0 ? +detail::has_named_args_bit : 0)),
26272623
values_(s.args) {}
26282624

2629-
template <int NUM_ARGS, int NUM_NAMED_ARGS, unsigned long long DESC,
2625+
template <int NUM_ARGS, int NUM_NAMED_ARGS, ullong DESC,
26302626
FMT_ENABLE_IF(NUM_ARGS > detail::max_packed_args)>
26312627
constexpr basic_format_args(const store<NUM_ARGS, NUM_NAMED_ARGS, DESC>& s)
26322628
: desc_(DESC | (NUM_NAMED_ARGS != 0 ? +detail::has_named_args_bit : 0)),
@@ -2670,8 +2666,7 @@ template <typename Context> class basic_format_args {
26702666
}
26712667

26722668
auto max_size() const -> int {
2673-
unsigned long long max_packed = detail::max_packed_args;
2674-
return static_cast<int>(is_packed() ? max_packed
2669+
return static_cast<int>(is_packed() ? ullong(detail::max_packed_args)
26752670
: desc_ & ~detail::is_unpacked_bit);
26762671
}
26772672
};
@@ -2816,7 +2811,7 @@ struct formatter<T, Char,
28162811
template <typename Context = context, typename... T,
28172812
int NUM_ARGS = sizeof...(T),
28182813
int NUM_NAMED_ARGS = detail::count_named_args<T...>(),
2819-
unsigned long long DESC = detail::make_descriptor<Context, T...>()>
2814+
ullong DESC = detail::make_descriptor<Context, T...>()>
28202815
constexpr FMT_ALWAYS_INLINE auto make_format_args(T&... args)
28212816
-> detail::format_arg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC> {
28222817
// Suppress warnings for pathological types convertible to detail::value.

include/fmt/chrono.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,7 @@ namespace detail {
544544
// https://johnnylee-sde.github.io/Fast-unsigned-integer-to-time-string/.
545545
inline void write_digit2_separated(char* buf, unsigned a, unsigned b,
546546
unsigned c, char sep) {
547-
unsigned long long digits =
548-
a | (b << 24) | (static_cast<unsigned long long>(c) << 48);
547+
ullong digits = a | (b << 24) | (static_cast<ullong>(c) << 48);
549548
// Convert each value to BCD.
550549
// We have x = a * 10 + b and we want to convert it to BCD y = a * 16 + b.
551550
// The difference is
@@ -559,7 +558,7 @@ inline void write_digit2_separated(char* buf, unsigned a, unsigned b,
559558
// Put low nibbles to high bytes and high nibbles to low bytes.
560559
digits = ((digits & 0x00f00000f00000f0) >> 4) |
561560
((digits & 0x000f00000f00000f) << 8);
562-
auto usep = static_cast<unsigned long long>(sep);
561+
auto usep = static_cast<ullong>(sep);
563562
// Add ASCII '0' to each digit byte and insert separators.
564563
digits |= 0x3030003030003030 | (usep << 16) | (usep << 40);
565564

include/fmt/format.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,11 @@ class uint128_fallback {
394394
return *this;
395395
}
396396
#if FMT_HAS_BUILTIN(__builtin_addcll) && !defined(__ibmxl__)
397-
unsigned long long carry;
397+
ullong carry;
398398
lo_ = __builtin_addcll(lo_, n, 0, &carry);
399399
hi_ += carry;
400400
#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) && !defined(__ibmxl__)
401-
unsigned long long result;
401+
ullong result;
402402
auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result);
403403
lo_ = result;
404404
hi_ += carry;
@@ -1645,7 +1645,7 @@ template <typename F> struct basic_fp {
16451645
}
16461646
};
16471647

1648-
using fp = basic_fp<unsigned long long>;
1648+
using fp = basic_fp<ullong>;
16491649

16501650
// Normalizes the value converted from double and multiplied by (1 << SHIFT).
16511651
template <int SHIFT = 0, typename F>
@@ -3733,12 +3733,12 @@ template <typename Char> struct arg_formatter {
37333733

37343734
struct dynamic_spec_getter {
37353735
template <typename T, FMT_ENABLE_IF(is_integer<T>::value)>
3736-
FMT_CONSTEXPR auto operator()(T value) -> unsigned long long {
3737-
return is_negative(value) ? ~0ull : static_cast<unsigned long long>(value);
3736+
FMT_CONSTEXPR auto operator()(T value) -> ullong {
3737+
return is_negative(value) ? ~0ull : static_cast<ullong>(value);
37383738
}
37393739

37403740
template <typename T, FMT_ENABLE_IF(!is_integer<T>::value)>
3741-
FMT_CONSTEXPR auto operator()(T) -> unsigned long long {
3741+
FMT_CONSTEXPR auto operator()(T) -> ullong {
37423742
report_error("width/precision is not integer");
37433743
return 0;
37443744
}
@@ -3752,7 +3752,7 @@ FMT_CONSTEXPR void handle_dynamic_spec(
37523752
auto arg =
37533753
kind == arg_id_kind::index ? ctx.arg(ref.index) : ctx.arg(ref.name);
37543754
if (!arg) report_error("argument not found");
3755-
unsigned long long result = arg.visit(dynamic_spec_getter());
3755+
ullong result = arg.visit(dynamic_spec_getter());
37563756
if (result > to_unsigned(max_value<int>()))
37573757
report_error("width/precision is out of range");
37583758
value = static_cast<int>(result);
@@ -3982,8 +3982,7 @@ class formatter<std::basic_string<Char, Traits, Allocator>, Char>
39823982
template <int N, typename Char>
39833983
struct formatter<detail::bitint<N>, Char> : formatter<long long, Char> {};
39843984
template <int N, typename Char>
3985-
struct formatter<detail::ubitint<N>, Char>
3986-
: formatter<unsigned long long, Char> {};
3985+
struct formatter<detail::ubitint<N>, Char> : formatter<ullong, Char> {};
39873986

39883987
template <typename Char>
39893988
struct formatter<detail::float128, Char>
@@ -4210,7 +4209,7 @@ class format_int {
42104209
private:
42114210
// Buffer should be large enough to hold all digits (digits10 + 1),
42124211
// a sign and a null character.
4213-
enum { buffer_size = std::numeric_limits<unsigned long long>::digits10 + 3 };
4212+
enum { buffer_size = std::numeric_limits<ullong>::digits10 + 3 };
42144213
mutable char buffer_[buffer_size];
42154214
char* str_;
42164215

@@ -4240,7 +4239,7 @@ class format_int {
42404239
: str_(format_unsigned(value)) {}
42414240
FMT_CONSTEXPR20 explicit format_int(unsigned long value)
42424241
: str_(format_unsigned(value)) {}
4243-
FMT_CONSTEXPR20 explicit format_int(unsigned long long value)
4242+
FMT_CONSTEXPR20 explicit format_int(ullong value)
42444243
: str_(format_unsigned(value)) {}
42454244

42464245
/// Returns the number of characters written to the output buffer.

0 commit comments

Comments
 (0)