[libcxx-commits] [libcxx] r364802 - Implement LWG2221: 'Formatted output for nullptr_t' Reviewed as: https://reviews.llvm.org/D63053

Marshall Clow via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 1 09:20:25 PDT 2019


Author: marshall
Date: Mon Jul  1 09:20:25 2019
New Revision: 364802

URL: http://llvm.org/viewvc/llvm-project?rev=364802&view=rev
Log:
Implement LWG2221: 'Formatted output for nullptr_t' Reviewed as: https://reviews.llvm.org/D63053

Modified:
    libcxx/trunk/include/ostream
    libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
    libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/ostream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ostream?rev=364802&r1=364801&r2=364802&view=diff
==============================================================================
--- libcxx/trunk/include/ostream (original)
+++ libcxx/trunk/include/ostream Mon Jul  1 09:20:25 2019
@@ -56,6 +56,7 @@ public:
     basic_ostream& operator<<(long double f);
     basic_ostream& operator<<(const void* p);
     basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb);
+    basic_ostream& operator<<(nullptr_t);
 
     // 27.7.2.7 Unformatted output:
     basic_ostream& put(char_type c);
@@ -218,6 +219,10 @@ public:
     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 << "nullptr"; }
+
     // 27.7.2.7 Unformatted output:
     basic_ostream& put(char_type __c);
     basic_ostream& write(const char_type* __s, streamsize __n);

Modified: libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp?rev=364802&r1=364801&r2=364802&view=diff
==============================================================================
--- libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp (original)
+++ libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp Mon Jul  1 09:20:25 2019
@@ -67,6 +67,13 @@ int main(int, char**)
         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;
 }

Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=364802&r1=364801&r2=364802&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Jul  1 09:20:25 2019
@@ -364,7 +364,7 @@
  	<tr><td></td><td></td><td></td><td></td></tr>
 	<tr><td><a href="https://wg21.link/LWG2062">2062</a></td><td>Effect contradictions w/o no-throw guarantee of std::function swaps</td><td>Issaquah</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2166">2166</a></td><td>Heap property underspecified?</td><td>Issaquah</td><td></td></tr>
-	<tr><td><a href="https://wg21.link/LWG2221">2221</a></td><td>No formatted output operator for nullptr</td><td>Issaquah</td><td></td></tr>
+	<tr><td><a href="https://wg21.link/LWG2221">2221</a></td><td>No formatted output operator for nullptr</td><td>Issaquah</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2223">2223</a></td><td>shrink_to_fit effect on iterator validity</td><td>Issaquah</td><td>Complete</td></tr>
 	<tr><td><a href="https://wg21.link/LWG2261">2261</a></td><td>Are containers required to use their 'pointer' type internally?</td><td>Issaquah</td><td></td></tr>
 	<tr><td><a href="https://wg21.link/LWG2394">2394</a></td><td>locale::name specification unclear - what is implementation-defined?</td><td>Issaquah</td><td>Complete</td></tr>




More information about the libcxx-commits mailing list