[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 17:18:19 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG50cfb76e029b: [libc++] Define ostream nullptr inserter for >= C++17 only (authored by joe_loser).

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.445988.patch
Type: text/x-patch
Size: 1549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220720/5730a8fa/attachment.bin>


More information about the libcxx-commits mailing list