[libcxx-commits] [PATCH] D63053: Add nullptr output operator overload (2221)
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 10 11:47:08 PDT 2019
zoecarver updated this revision to Diff 203868.
zoecarver added a comment.
- fix inlining
- fix visibility
- fix `"nullptr"` output value
- update tests
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63053/new/
https://reviews.llvm.org/D63053
Files:
include/ostream
test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
Index: test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
===================================================================
--- test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
+++ test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
@@ -67,6 +67,13 @@
os << &sb2;
assert(sb.str() == "testing...");
}
+ { // LWG 2221 - nullptr
+ testbuf<char> sb;
+ std::ostream os(&sb);
+ os << nullptr;
+ assert(sb.str().size() != 0);
+ LIBCPP_ASSERT(sb.str() == "nullptr");
+ }
return 0;
}
Index: include/ostream
===================================================================
--- include/ostream
+++ include/ostream
@@ -218,6 +218,10 @@
basic_ostream& operator<<(const void* __p);
basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream& operator<<(nullptr_t)
+ { return *this << static_cast<const char*>("nullptr\0"); }
+
// 27.7.2.7 Unformatted output:
basic_ostream& put(char_type __c);
basic_ostream& write(const char_type* __s, streamsize __n);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63053.203868.patch
Type: text/x-patch
Size: 1282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190610/05dba7a6/attachment-0001.bin>
More information about the libcxx-commits
mailing list