This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.

### 3199. `istream >> bitset<0>` fails

Section: 20.9.4 [bitset.operators] Status: C++20 Submitter: Davis Herring Opened: 2019-04-05 Last modified: 2021-02-25

Priority: Not Prioritized

View all other issues in [bitset.operators].

View all issues with C++20 status.

Discussion:

From a StackOverflow question:

[bitset.operators]/5.1 says that extracting a `bitset<0>` stops after reading 0 characters. /6 then says that, since no characters were stored, `failbit` is set.

[2019-06-09; Priority to 0 and Status to Tentatively Ready after five positive votes on the reflector.]

Proposed resolution:

This wording is relative to N4810.

1. Modify 20.9.4 [bitset.operators] as indicated:

   >     template<class charT, class traits, size_t N>
   >       basic_istream<charT, traits>&
   >         operator>>(basic_istream<charT, traits>& is, bitset<N>& x);

   > > […]

   > > -6- If `N > 0` and no characters are stored in `str`, calls `is.setstate(ios_base::failbit)` (which may throw `ios_base::failure` (29.5.4.4 [iostate.flags])).