Index: include/ostream =================================================================== --- include/ostream +++ include/ostream @@ -216,6 +216,7 @@ basic_ostream& operator<<(double __f); basic_ostream& operator<<(long double __f); basic_ostream& operator<<(const void* __p); + basic_ostream& operator<<(nullptr_t); basic_ostream& operator<<(basic_streambuf* __sb); // 27.7.2.7 Unformatted output: @@ -709,6 +710,13 @@ return *this; } +template +basic_ostream<_CharT, _Traits>& +basic_ostream<_CharT, _Traits>::operator<<(nullptr_t) +{ + return *this << static_cast(0x0); +} + template basic_ostream<_CharT, _Traits>& __put_character_sequence(basic_ostream<_CharT, _Traits>& __os, 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,12 @@ os << &sb2; assert(sb.str() == "testing..."); } + { // LWG 2221 - nullptr + testbuf sb; + std::ostream os(&sb); + os << nullptr; + assert(sb.str().c_str()[0] == '0'); + } return 0; }