[libcxx-commits] [libcxx] r369422 - [libc++] Implement LWG 3199
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 20 11:21:06 PDT 2019
Author: ldionne
Date: Tue Aug 20 11:21:06 2019
New Revision: 369422
URL: http://llvm.org/viewvc/llvm-project?rev=369422&view=rev
Log:
[libc++] Implement LWG 3199
Summary:
The resolution of LWG 3199 makes sure that input-streaming into an empty bitset
does not set the failbit on the input stream.
Reviewers: mclow.lists, EricWF
Subscribers: christof, jkorous, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D65105
Modified:
libcxx/trunk/include/istream
libcxx/trunk/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp
libcxx/trunk/www/upcoming_meeting.html
Modified: libcxx/trunk/include/istream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=369422&r1=369421&r2=369422&view=diff
==============================================================================
--- libcxx/trunk/include/istream (original)
+++ libcxx/trunk/include/istream Tue Aug 20 11:21:06 2019
@@ -1619,7 +1619,7 @@ operator>>(basic_istream<_CharT, _Traits
__is.rdbuf()->sbumpc();
}
__x = bitset<_Size>(__str);
- if (__c == 0)
+ if (_Size > 0 && __c == 0)
__state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
}
Modified: libcxx/trunk/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp?rev=369422&r1=369421&r2=369422&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/template.bitset/bitset.operators/stream_in.pass.cpp Tue Aug 20 11:21:06 2019
@@ -25,6 +25,18 @@ int main(int, char**)
in >> b;
assert(b.to_ulong() == 0x5A);
}
+ {
+ // Make sure that input-streaming an empty bitset does not cause the
+ // failbit to be set (LWG 3199).
+ std::istringstream in("01011010");
+ std::bitset<0> b;
+ in >> b;
+ assert(b.to_string() == "");
+ assert(!in.bad());
+ assert(!in.fail());
+ assert(!in.eof());
+ assert(in.good());
+ }
#ifndef TEST_HAS_NO_EXCEPTIONS
{
std::stringbuf sb;
Modified: libcxx/trunk/www/upcoming_meeting.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=369422&r1=369421&r2=369422&view=diff
==============================================================================
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Tue Aug 20 11:21:06 2019
@@ -71,7 +71,7 @@
<tr><td><a href="https://wg21.link/LWG3191">3191</a></td><td>Yes</td><td><tt>std::ranges::shuffle</tt> synopsis does not match algorithm definition</td><td>Cologne</td><td></td></tr>
<tr><td><a href="https://wg21.link/LWG3196">3196</a></td><td>Yes</td><td><tt>std::optional<T></tt> is ill-formed is <tt>T</tt> is an array</td><td>Cologne</td><td>Complete</td></tr>
<tr><td><a href="https://wg21.link/LWG3198">3198</a></td><td>Yes</td><td>Bad constraint on <tt>std::span::span()</tt></td><td>Cologne</td><td>Complete</td></tr>
-<tr><td><a href="https://wg21.link/LWG3199">3199</a></td><td>Yes</td><td><tt>istream >> bitset<0></tt> fails</td><td>Cologne</td><td></td></tr>
+<tr><td><a href="https://wg21.link/LWG3199">3199</a></td><td>Yes</td><td><tt>istream >> bitset<0></tt> fails</td><td>Cologne</td><td>Complete</td></tr>
<tr><td><a href="https://wg21.link/LWG3202">3202</a></td><td>Yes</td><td>P0318R1 was supposed to be revised</td><td>Cologne</td><td>Complete</td></tr>
<tr><td><a href="https://wg21.link/LWG3206">3206</a></td><td>Yes</td><td><tt>year_month_day</tt> conversion to <tt>sys_days</tt> uses not-existing member function</td><td>Cologne</td><td>Complete</td></tr>
<tr><td><a href="https://wg21.link/LWG3208">3208</a></td><td>Yes</td><td><tt>Boolean</tt>'s expression requirements are ordered inconsistently</td><td>Cologne</td><td>Nothing to do</td></tr>
@@ -105,7 +105,6 @@
<li>3191 - We don't do ranges yet</li>
<li>3196 - We already do this</li>
<li>3198 - We already do this</li>
-<li>3199 - Louis</li>
<li>3202 - We already do this</li>
<li>3206 - We already do this; added a couple of explicit tests</li>
<li>3208 - Nothing to do; wording cleanup</li>
More information about the libcxx-commits
mailing list