[libcxx-commits] [PATCH] D127033: [libc++] Define ostream nullptr inserter for >= C++17 only
Joe Loser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 19 11:10:09 PDT 2022
jloser updated this revision to Diff 445886.
jloser edited the summary of this revision.
jloser added a comment.
Add comment about LWG 2221 not being backported.
Update commit message to provide brief rationale.
If CI passes, I'll ship this.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127033/new/
https://reviews.llvm.org/D127033
Files:
libcxx/include/ostream
libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
Index: libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
===================================================================
--- libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
+++ libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
@@ -67,13 +67,17 @@
os << &sb2;
assert(sb.str() == "testing...");
}
- { // LWG 2221 - nullptr
+#if TEST_STD_VER > 14
+// LWG 2221 - nullptr. This is not backported to older standards modes.
+// See https://reviews.llvm.org/D127033 for more info on the rationale.
+ {
testbuf<char> sb;
std::ostream os(&sb);
os << nullptr;
assert(sb.str().size() != 0);
LIBCPP_ASSERT(sb.str() == "nullptr");
}
+#endif
return 0;
}
Index: libcxx/include/ostream
===================================================================
--- libcxx/include/ostream
+++ libcxx/include/ostream
@@ -225,9 +225,13 @@
basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
+#if _LIBCPP_STD_VER > 14
+// LWG 2221 - nullptr. This is not backported to older standards modes.
+// See https://reviews.llvm.org/D127033 for more info on the rationale.
_LIBCPP_INLINE_VISIBILITY
basic_ostream& operator<<(nullptr_t)
{ return *this << "nullptr"; }
+#endif
// 27.7.2.7 Unformatted output:
basic_ostream& put(char_type __c);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127033.445886.patch
Type: text/x-patch
Size: 1549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220719/5b19b8ba/attachment.bin>
More information about the libcxx-commits
mailing list