This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Implement P0487R1 - Fixing operator>>(basic_istream&, CharT*)

Authored by lichray on Aug 25 2018, 11:04 PM.

Diff Detail

rCXX libc++

Event Timeline

lichray created this revision.Aug 25 2018, 11:04 PM
ldionne accepted this revision.Nov 19 2018, 10:59 AM
ldionne added inline comments.

Should this instead be if (__n == 0)? Can width() ever return a negative number? cppreference says this about streamsize:

Except in the constructors of std::strstreambuf, negative values of std::streamsize are never used.

I couldn't find a matching statement in the standard, however there's this footnote in 30.5.2:

streamsize is used in most places where ISO C would use size_t. Most of the uses of streamsize could use size_t, except for the strstreambuf constructors, which require negative values. It should probably be the signed type corresponding to size_t (which is what Posix.2 calls ssize_t).

This does not clearly say that negative values are never used, but it does suggest it. Maybe it's safer to still use __n <= 0.

This revision is now accepted and ready to land.Nov 19 2018, 10:59 AM

My interpretation of is that you can retrieve the value you set through width(streamsize). And the wording here (unmodified) says "If width() is greater than zero, [...]," so the opposite should be width() <= 0.

lichray updated this revision to Diff 174722.Nov 19 2018, 10:42 PM

Update cxx2a status.

This revision was automatically updated to reflect the committed changes.