Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7015f30

Browse filesBrowse files
wooffieaduh95
authored andcommitted
src: add enum handle for ToStringHelper + formatting
Fixes: #56666 PR-URL: #56829 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 07fa6c9 commit 7015f30
Copy full SHA for 7015f30

File tree

Expand file treeCollapse file tree

1 file changed

+8
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-9
lines changed
Open diff view settings
Collapse file

‎src/debug_utils-inl.h‎

Copy file name to clipboardExpand all lines: src/debug_utils-inl.h
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ struct ToStringHelper {
3838

3939
template <typename T,
4040
typename test_for_number = typename std::
41-
enable_if<std::is_arithmetic<T>::value, bool>::type,
41+
enable_if_t<std::is_arithmetic_v<T> || std::is_enum_v<T>, bool>,
4242
typename dummy = bool>
43-
static std::string Convert(const T& value) { return std::to_string(value); }
43+
static std::string Convert(const T& value) {
44+
return std::to_string(value);
45+
}
4446
static std::string_view Convert(const char* value) {
4547
return value != nullptr ? value : "(null)";
4648
}
@@ -58,8 +60,7 @@ struct ToStringHelper {
5860
const char* digits = "0123456789abcdef";
5961
do {
6062
unsigned digit = v & ((1 << BASE_BITS) - 1);
61-
*--ptr =
62-
(BASE_BITS < 4 ? static_cast<char>('0' + digit) : digits[digit]);
63+
*--ptr = (BASE_BITS < 4 ? static_cast<char>('0' + digit) : digits[digit]);
6364
} while ((v >>= BASE_BITS) != 0);
6465
return ptr;
6566
}
@@ -139,12 +140,10 @@ std::string COLD_NOINLINE SPrintFImpl( // NOLINT(runtime/string)
139140
ret += node::ToUpper(ToBaseString<4>(arg));
140141
break;
141142
case 'p': {
142-
CHECK(std::is_pointer<typename std::remove_reference<Arg>::type>::value);
143+
CHECK(std::is_pointer_v<typename std::remove_reference_t<Arg>>);
143144
char out[20];
144-
int n = snprintf(out,
145-
sizeof(out),
146-
"%p",
147-
*reinterpret_cast<const void* const*>(&arg));
145+
int n = snprintf(
146+
out, sizeof(out), "%p", *reinterpret_cast<const void* const*>(&arg));
148147
CHECK_GE(n, 0);
149148
ret += out;
150149
break;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.