Skip to content

Commit 85f285a

Browse files
committed
Remove some redundant consts
`constexpr` variables are implicitly `const`.
1 parent 7af94e5 commit 85f285a

6 files changed

Lines changed: 29 additions & 31 deletions

File tree

include/fmt/chrono.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ inline auto get_classic_locale() -> const std::locale& {
326326
}
327327

328328
template <typename CodeUnit> struct codecvt_result {
329-
static constexpr const size_t max_size = 32;
329+
static constexpr size_t max_size = 32;
330330
CodeUnit buf[max_size];
331331
CodeUnit* end;
332332
};
@@ -652,7 +652,7 @@ inline void write_digit2_separated(char* buf, unsigned a, unsigned b,
652652
// Add ASCII '0' to each digit byte and insert separators.
653653
digits |= 0x3030003030003030 | (usep << 16) | (usep << 40);
654654

655-
constexpr const size_t len = 8;
655+
constexpr size_t len = 8;
656656
if (const_check(is_big_endian())) {
657657
char tmp[len];
658658
std::memcpy(tmp, &digits, len);

include/fmt/format-inl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ template <> struct cache_accessor<float> {
275275
static auto get_cached_power(int k) noexcept -> uint64_t {
276276
FMT_ASSERT(k >= float_info<float>::min_k && k <= float_info<float>::max_k,
277277
"k is out of range");
278-
static constexpr const uint64_t pow10_significands[] = {
278+
static constexpr uint64_t pow10_significands[] = {
279279
0x81ceb32c4b43fcf5, 0xa2425ff75e14fc32, 0xcad2f7f5359a3b3f,
280280
0xfd87b5f28300ca0e, 0x9e74d1b791e07e49, 0xc612062576589ddb,
281281
0xf79687aed3eec552, 0x9abe14cd44753b53, 0xc16d9a0095928a28,
@@ -370,7 +370,7 @@ template <> struct cache_accessor<double> {
370370
FMT_ASSERT(k >= float_info<double>::min_k && k <= float_info<double>::max_k,
371371
"k is out of range");
372372

373-
static constexpr const uint128_fallback pow10_significands[] = {
373+
static constexpr uint128_fallback pow10_significands[] = {
374374
#if FMT_USE_FULL_CACHE_DRAGONBOX
375375
{0xff77b1fcbebcdc4f, 0x25e8e89c13bb0f7b},
376376
{0x9faacf3df73609b1, 0x77b191618c54e9ad},
@@ -1037,7 +1037,7 @@ template <> struct cache_accessor<double> {
10371037
#if FMT_USE_FULL_CACHE_DRAGONBOX
10381038
return pow10_significands[k - float_info<double>::min_k];
10391039
#else
1040-
static constexpr const uint64_t powers_of_5_64[] = {
1040+
static constexpr uint64_t powers_of_5_64[] = {
10411041
0x0000000000000001, 0x0000000000000005, 0x0000000000000019,
10421042
0x000000000000007d, 0x0000000000000271, 0x0000000000000c35,
10431043
0x0000000000003d09, 0x000000000001312d, 0x000000000005f5e1,

include/fmt/format.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,10 @@ FMT_CONSTEXPR FMT_NOINLINE auto copy_noinline(InputIt begin, InputIt end,
555555
*/
556556
FMT_CONSTEXPR inline auto utf8_decode(const char* s, uint32_t* c, int* e)
557557
-> const char* {
558-
constexpr const int masks[] = {0x00, 0x7f, 0x1f, 0x0f, 0x07};
559-
constexpr const uint32_t mins[] = {4194304, 0, 128, 2048, 65536};
560-
constexpr const int shiftc[] = {0, 18, 12, 6, 0};
561-
constexpr const int shifte[] = {0, 6, 4, 2, 0};
558+
constexpr int masks[] = {0x00, 0x7f, 0x1f, 0x0f, 0x07};
559+
constexpr uint32_t mins[] = {4194304, 0, 128, 2048, 65536};
560+
constexpr int shiftc[] = {0, 18, 12, 6, 0};
561+
constexpr int shifte[] = {0, 6, 4, 2, 0};
562562

563563
int len = "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\0\0\0\0\0\0\0\0\2\2\2\2\3\3\4"
564564
[static_cast<unsigned char>(*s) >> 3];
@@ -1044,7 +1044,7 @@ inline auto do_count_digits(uint64_t n) -> int {
10441044
10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 15, 15,
10451045
15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 19, 20};
10461046
auto t = bsr2log10[FMT_BUILTIN_CLZLL(n | 1) ^ 63];
1047-
static constexpr const uint64_t zero_or_powers_of_10[] = {
1047+
static constexpr uint64_t zero_or_powers_of_10[] = {
10481048
0, 0, FMT_POWERS_OF_10(1U), FMT_POWERS_OF_10(1000000000ULL),
10491049
10000000000000000000ULL};
10501050
return t - (n < zero_or_powers_of_10[t]);
@@ -1519,7 +1519,7 @@ template <typename F> struct basic_fp {
15191519
F f;
15201520
int e;
15211521

1522-
static constexpr const int num_significand_bits =
1522+
static constexpr int num_significand_bits =
15231523
static_cast<int>(sizeof(F) * num_bits<unsigned char>());
15241524

15251525
constexpr basic_fp() : f(0), e(0) {}
@@ -1964,8 +1964,7 @@ FMT_CONSTEXPR auto make_write_int_arg(T value, sign s)
19641964
prefix = 0x01000000 | '-';
19651965
abs_value = 0 - abs_value;
19661966
} else {
1967-
constexpr const unsigned prefixes[4] = {0, 0, 0x1000000u | '+',
1968-
0x1000000u | ' '};
1967+
constexpr unsigned prefixes[4] = {0, 0, 0x1000000u | '+', 0x1000000u | ' '};
19691968
prefix = prefixes[static_cast<int>(s)];
19701969
}
19711970
return {abs_value, prefix};

include/fmt/ranges.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ template <typename T> class is_map {
3030
template <typename> static void check(...);
3131

3232
public:
33-
static constexpr const bool value =
33+
static constexpr bool value =
3434
!std::is_void<decltype(check<T>(nullptr))>::value;
3535
};
3636

@@ -39,7 +39,7 @@ template <typename T> class is_set {
3939
template <typename> static void check(...);
4040

4141
public:
42-
static constexpr const bool value =
42+
static constexpr bool value =
4343
!std::is_void<decltype(check<T>(nullptr))>::value && !is_map<T>::value;
4444
};
4545

@@ -118,7 +118,7 @@ template <typename T> class is_tuple_like_ {
118118
template <typename> static void check(...);
119119

120120
public:
121-
static constexpr const bool value =
121+
static constexpr bool value =
122122
!std::is_void<decltype(check<T>(nullptr))>::value;
123123
};
124124

@@ -152,7 +152,7 @@ using tuple_index_sequence = make_index_sequence<std::tuple_size<T>::value>;
152152
template <typename T, typename C, bool = is_tuple_like_<T>::value>
153153
class is_tuple_formattable_ {
154154
public:
155-
static constexpr const bool value = false;
155+
static constexpr bool value = false;
156156
};
157157
template <typename T, typename C> class is_tuple_formattable_<T, C, true> {
158158
template <size_t... Is>
@@ -168,7 +168,7 @@ template <typename T, typename C> class is_tuple_formattable_<T, C, true> {
168168
C>::value)...>{}));
169169

170170
public:
171-
static constexpr const bool value =
171+
static constexpr bool value =
172172
decltype(check(tuple_index_sequence<T>{}))::value;
173173
};
174174

@@ -280,13 +280,12 @@ template <typename FormatContext> struct format_tuple_element {
280280
} // namespace detail
281281

282282
template <typename T> struct is_tuple_like {
283-
static constexpr const bool value =
283+
static constexpr bool value =
284284
detail::is_tuple_like_<T>::value && !detail::is_range_<T>::value;
285285
};
286286

287287
template <typename T, typename C> struct is_tuple_formattable {
288-
static constexpr const bool value =
289-
detail::is_tuple_formattable_<T, C>::value;
288+
static constexpr bool value = detail::is_tuple_formattable_<T, C>::value;
290289
};
291290

292291
template <typename Tuple, typename Char>
@@ -342,7 +341,7 @@ struct formatter<Tuple, Char,
342341
};
343342

344343
template <typename T, typename Char> struct is_range {
345-
static constexpr const bool value =
344+
static constexpr bool value =
346345
detail::is_range_<T>::value && !detail::has_to_string_view<T>::value;
347346
};
348347

@@ -752,7 +751,7 @@ template <typename T> class is_container_adaptor_like {
752751
template <typename> static void check(...);
753752

754753
public:
755-
static constexpr const bool value =
754+
static constexpr bool value =
756755
!std::is_void<decltype(check<T>(nullptr))>::value;
757756
};
758757

include/fmt/std.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ template <typename Variant, typename Char> class is_variant_formattable {
134134
check(std::index_sequence<Is...>);
135135

136136
public:
137-
static constexpr const bool value = decltype(check(
137+
static constexpr bool value = decltype(check(
138138
std::make_index_sequence<std::variant_size<Variant>::value>()))::value;
139139
};
140140

@@ -218,17 +218,17 @@ struct has_flip<T, void_t<decltype(std::declval<T>().flip())>>
218218
: std::true_type {};
219219

220220
template <typename T> struct is_bit_reference_like {
221-
static constexpr const bool value =
222-
std::is_convertible<T, bool>::value &&
223-
std::is_nothrow_assignable<T, bool>::value && has_flip<T>::value;
221+
static constexpr bool value = std::is_convertible<T, bool>::value &&
222+
std::is_nothrow_assignable<T, bool>::value &&
223+
has_flip<T>::value;
224224
};
225225

226226
// Workaround for libc++ incompatibility with C++ standard.
227227
// According to the Standard, `bitset::operator[] const` returns bool.
228228
#ifdef _LIBCPP_VERSION
229229
template <typename C>
230230
struct is_bit_reference_like<std::__bit_const_reference<C>> {
231-
static constexpr const bool value = true;
231+
static constexpr bool value = true;
232232
};
233233
#endif
234234

@@ -443,7 +443,7 @@ template <> struct formatter<std::source_location> {
443443
#if FMT_CPP_LIB_VARIANT
444444

445445
template <typename T> struct is_variant_like {
446-
static constexpr const bool value = detail::is_variant_like_<T>::value;
446+
static constexpr bool value = detail::is_variant_like_<T>::value;
447447
};
448448

449449
template <typename Char> struct formatter<std::monostate, Char> {

test/format-test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,8 +1940,8 @@ TEST(format_test, unpacked_args) {
19401940

19411941
constexpr char with_null[3] = {'{', '}', '\0'};
19421942
constexpr char no_null[2] = {'{', '}'};
1943-
static constexpr const char static_with_null[3] = {'{', '}', '\0'};
1944-
static constexpr const char static_no_null[2] = {'{', '}'};
1943+
static constexpr char static_with_null[3] = {'{', '}', '\0'};
1944+
static constexpr char static_no_null[2] = {'{', '}'};
19451945

19461946
TEST(format_test, compile_time_string) {
19471947
EXPECT_EQ(fmt::format(FMT_STRING("foo")), "foo");

0 commit comments

Comments
 (0)