Title
Bad sentry example
Status
tc1
Section
[istream.sentry]
Submitter
Nathan Myers

Created on 1998-08-06.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

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.

Date: 2010-10-21.18:28:33

Proposed resolution:

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

Date: 1998-08-06.00:00:00

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.)

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg60
2010-10-21 18:28:33adminsetmessages: + msg59
1998-08-06 00:00:00admincreate