Commit ce4a65ff authored by Victor Zverovich's avatar Victor Zverovich

Add pointer support to basic_writer

parent 91721caa
...@@ -2553,6 +2553,14 @@ class basic_writer { ...@@ -2553,6 +2553,14 @@ class basic_writer {
void write(basic_string_view<char_type> str, FormatSpecs... specs) { void write(basic_string_view<char_type> str, FormatSpecs... specs) {
write_str(str, format_specs(specs...)); write_str(str, format_specs(specs...));
} }
template <typename T>
typename std::enable_if<std::is_same<T, void>::value>::type write(const T* p) {
format_specs specs;
specs.flags_ = HASH_FLAG;
specs.type_ = 'x';
write_int(reinterpret_cast<uintptr_t>(p), specs);
}
}; };
template <typename Range> template <typename Range>
......
...@@ -1609,6 +1609,7 @@ TEST(FormatTest, UdlTemplate) { ...@@ -1609,6 +1609,7 @@ TEST(FormatTest, UdlTemplate) {
TEST(FormatTest, ToString) { TEST(FormatTest, ToString) {
EXPECT_EQ("42", fmt::to_string(42)); EXPECT_EQ("42", fmt::to_string(42));
EXPECT_EQ("0x1234", fmt::to_string(reinterpret_cast<void*>(0x1234)));
} }
TEST(FormatTest, ToWString) { TEST(FormatTest, ToWString) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment