[libcxx-commits] [PATCH] D63053: Add nullptr output operator overload (2221)
Marshall Clow via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 10 06:53:37 PDT 2019
mclow.lists added inline comments.
================
Comment at: include/ostream:717
+{
+ return *this << static_cast<const void*>(0x0);
+}
----------------
EricWF wrote:
> `static_cast<const void*>(nullptr)`;
>
> But I'm not sure we want to forward to the `const void*` overload. My understanding of that overload is that it exists to print "bool" values for types like `ostream` that used to implement `if (stream)` via a conversion to `void*`.
>
> I think we may just want to print `nill`.
I suggested this approach to Zoe, because I thought that that was what GCC did. (print `0x0`)
Turns out that I was wrong; GCC prints `nullptr` (at least that's what wandbox claims about gcc 9).
================
Comment at: test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp:74
+ os << nullptr;
+ assert(sb.str().c_str()[0] == '0');
+ }
----------------
EricWF wrote:
> I don't think this test is portable. Implementations can print `null` or `nill` or "hubbabalo" for that matter.
> We should probably just make this a `LIBCPP_ASSERT`. And maybe we should also assert the string isn't empty (for when other STL's use our test suite).
Agreed.
Repository:
rCXX libc++
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63053/new/
https://reviews.llvm.org/D63053
More information about the libcxx-commits
mailing list