diff --git a/include/ostream b/include/ostream index b20ac34a3..e6cf9c970 100644 --- a/include/ostream +++ b/include/ostream @@ -56,6 +56,7 @@ public: basic_ostream& operator<<(long double f); basic_ostream& operator<<(const void* p); basic_ostream& operator<<(basic_streambuf* 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* __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); diff --git a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp index daf5ba102..af411157e 100644 --- a/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp +++ b/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp @@ -67,6 +67,13 @@ int main(int, char**) os << &sb2; assert(sb.str() == "testing..."); } + { // LWG 2221 - nullptr + testbuf sb; + std::ostream os(&sb); + os << nullptr; + assert(sb.str().size() != 0); + LIBCPP_ASSERT(sb.str() == "nullptr"); + } return 0; } diff --git a/www/cxx1z_status.html b/www/cxx1z_status.html index 94950ded2..5427d4880 100644 --- a/www/cxx1z_status.html +++ b/www/cxx1z_status.html @@ -364,7 +364,7 @@ 2062Effect contradictions w/o no-throw guarantee of std::function swapsIssaquahComplete 2166Heap property underspecified?Issaquah - 2221No formatted output operator for nullptrIssaquah + 2221No formatted output operator for nullptrIssaquahComplete 2223shrink_to_fit effect on iterator validityIssaquahComplete 2261Are containers required to use their 'pointer' type internally?Issaquah 2394locale::name specification unclear - what is implementation-defined?IssaquahComplete