[PATCH] D33776: [libcxx] LWG2221: No formatted output operator for nullptr

Marshall Clow via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 13 09:32:46 PST 2017


mclow.lists added a comment.

Other than the actual text being output, this LGTM.
I'ld like to see the changes I suggested in the test go in, but they're really minor.



================
Comment at: include/ostream:225
+    basic_ostream& operator<<(nullptr_t)
+    { return *this << (const void*)0; }
+
----------------
lichray wrote:
> Oh, common, I persuaded the committee to allow you to print a `(null)`  and you don't do it...
I think that `(null)` is a better thing to output here than `0x0`.


================
Comment at: test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/nullptr_t.pass.cpp:72
+        // at least ensure that it does not generate an empty string.
+        assert(!s.empty());
+    }
----------------
You could just say `assert(!sb.str().empty()) here; no need to save the string in a variable.


================
Comment at: test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/nullptr_t.pass.cpp:79
+        os << n;
+        assert(os.good());
+    }
----------------
Might as well check for a non-empty string here, too.


https://reviews.llvm.org/D33776





More information about the cfe-commits mailing list