[PATCH] istream_iterator: unexpected read in ctor

Petr Ovtchenkov ptr@void-ptr.info
Mon Aug 28 09:26:00 GMT 2017


Summary:

  Standard say (with a bit misoriented words):

     27.6.1  Class template istream_iterator [istream.iterator]
     1 The class template istream_iterator is an input iterator (27.2.3)
       that reads (using operator>>) successive elements from the input
       stream for which it was constructed.
    ->    After it is constructed, and every time ++ is used, the iterator
    ->    reads and stores a value of T.
     ...

     27.6.1.1 istream_iterator constructors and destructor [istream.iterator.cons]
     ...
     istream_iterator(istream_type& s);
    ->  3 Effects: Initializes in_stream with addressof(s). value may be initialized
    ->    during construction or the first time it is referenced.
     4 Postconditions: in_stream == addressof(s).

  Current position is "After it is constructed ... the iterator reads and stores
  a value of T.": http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0738r0.html

IMO the test (modified according words above) is still useful, I will re-submit it ASAP.

--

   - ptr



More information about the Libstdc++ mailing list