Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/debug_utils-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ struct ToStringHelper {

template <typename T,
typename test_for_number = typename std::
enable_if<std::is_arithmetic<T>::value, bool>::type,
enable_if_t<std::is_arithmetic_v<T> || std::is_enum_v<T>, bool>,
typename dummy = bool>
static std::string Convert(const T& value) { return std::to_string(value); }
static std::string Convert(const T& value) {
return std::to_string(value);
}
static std::string_view Convert(const char* value) {
return value != nullptr ? value : "(null)";
}
Expand All @@ -58,8 +60,7 @@ struct ToStringHelper {
const char* digits = "0123456789abcdef";
do {
unsigned digit = v & ((1 << BASE_BITS) - 1);
*--ptr =
(BASE_BITS < 4 ? static_cast<char>('0' + digit) : digits[digit]);
*--ptr = (BASE_BITS < 4 ? static_cast<char>('0' + digit) : digits[digit]);
} while ((v >>= BASE_BITS) != 0);
return ptr;
}
Expand Down Expand Up @@ -139,12 +140,10 @@ std::string COLD_NOINLINE SPrintFImpl( // NOLINT(runtime/string)
ret += node::ToUpper(ToBaseString<4>(arg));
break;
case 'p': {
CHECK(std::is_pointer<typename std::remove_reference<Arg>::type>::value);
CHECK(std::is_pointer_v<typename std::remove_reference_t<Arg>>);
char out[20];
int n = snprintf(out,
sizeof(out),
"%p",
*reinterpret_cast<const void* const*>(&arg));
int n = snprintf(
out, sizeof(out), "%p", *reinterpret_cast<const void* const*>(&arg));
CHECK_GE(n, 0);
ret += out;
break;
Expand Down
Loading