mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-04 17:26:42 +00:00
Add nullptr support
This commit is contained in:
parent
80505995d0
commit
8a2bc0ab1b
@ -1267,6 +1267,7 @@ template <> constexpr Type gettype<std::wstring>() { return TSTRING; }
|
|||||||
template <> constexpr Type gettype<wstring_view>() { return TSTRING; }
|
template <> constexpr Type gettype<wstring_view>() { return TSTRING; }
|
||||||
template <> constexpr Type gettype<void *>() { return POINTER; }
|
template <> constexpr Type gettype<void *>() { return POINTER; }
|
||||||
template <> constexpr Type gettype<const void *>() { return POINTER; }
|
template <> constexpr Type gettype<const void *>() { return POINTER; }
|
||||||
|
template <> constexpr Type gettype<std::nullptr_t>() { return POINTER; }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr Type type() { return gettype<typename std::decay<T>::type>(); }
|
constexpr Type type() { return gettype<typename std::decay<T>::type>(); }
|
||||||
@ -1419,6 +1420,7 @@ class value {
|
|||||||
|
|
||||||
FMT_MAKE_VALUE(void *, pointer, POINTER)
|
FMT_MAKE_VALUE(void *, pointer, POINTER)
|
||||||
FMT_MAKE_VALUE(const void *, pointer, POINTER)
|
FMT_MAKE_VALUE(const void *, pointer, POINTER)
|
||||||
|
value(std::nullptr_t) { pointer = nullptr; }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
value(const T &value,
|
value(const T &value,
|
||||||
|
@ -1219,6 +1219,7 @@ TEST(FormatterTest, FormatPointer) {
|
|||||||
EXPECT_EQ("0x" + std::string(sizeof(void*) * CHAR_BIT / 4, 'f'),
|
EXPECT_EQ("0x" + std::string(sizeof(void*) * CHAR_BIT / 4, 'f'),
|
||||||
format("{0}", reinterpret_cast<void*>(~uintptr_t())));
|
format("{0}", reinterpret_cast<void*>(~uintptr_t())));
|
||||||
EXPECT_EQ("0x1234", format("{}", fmt::ptr(reinterpret_cast<int*>(0x1234))));
|
EXPECT_EQ("0x1234", format("{}", fmt::ptr(reinterpret_cast<int*>(0x1234))));
|
||||||
|
EXPECT_EQ("0x0", format("{}", nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FormatterTest, FormatString) {
|
TEST(FormatterTest, FormatString) {
|
||||||
|
Loading…
Reference in New Issue
Block a user