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

### 26. Bad sentry example

Section: 29.7.4.2.4 [istream.sentry] Status: TC1 Submitter: Nathan Myers Opened: 1998-08-06 Last modified: 2021-06-06

Priority: Not Prioritized

View all other issues in [istream.sentry].

View all issues with TC1 status.

Discussion:

In paragraph 6, the code in the example:

      template <class charT, class traits = char_traits<charT> >
      basic_istream<charT,traits>::sentry(
               basic_istream<charT,traits>& is, bool noskipws = false) {
          ...
          int_type c;
          typedef ctype<charT> ctype_type;
          const ctype_type& ctype = use_facet<ctype_type>(is.getloc());
          while ((c = is.rdbuf()->snextc()) != traits::eof()) {
            if (ctype.is(ctype.space,c)==0) {
              is.rdbuf()->sputbackc (c);
              break;
            }
          }
          ...
       }

fails to demonstrate correct use of the facilities described. In particular, it fails to use traits operators, and specifies incorrect semantics. (E.g. it specifies skipping over the first character in the sequence without examining it.)

Proposed resolution:

Remove the example above from [istream::sentry] paragraph 6.

Rationale:

The originally proposed replacement code for the example was not correct. The LWG tried in Kona and again in Tokyo to correct it without success. In Tokyo, an implementor reported that actual working code ran over one page in length and was quite complicated. The LWG decided that it would be counter-productive to include such a lengthy example, which might well still contain errors.