Title
Missing DefaultConstructible requirement for istream_iterator default constructor
Status
c++17
Section
[istream.iterator.cons]
Submitter
United States

Created on 2017-02-03.00:00:00 last changed 90 months ago

Messages

Date: 2017-03-03.22:19:58

Proposed resolution:

This wording is relative to N4618.

  1. Modify [istream.iterator] as indicated:

    -1- The class template istream_iterator is an input iterator (24.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. If the iterator fails to read and store a value of T (fail() on the stream returns true), the iterator becomes equal to the end-of-stream iterator value. The constructor with no arguments istream_iterator() always constructs an end-of-stream input iterator object, which is the only legitimate iterator to be used for the end condition. The result of operator* on an end-of-stream iterator is not defined. For any other iterator value a const T& is returned. The result of operator-> on an end-of-stream iterator is not defined. For any other iterator value a const T* is returned. The behavior of a program that applies operator++() to an end-of-stream iterator is undefined. It is impossible to store things into istream iterators. The type T shall meet the DefaultConstructible, CopyConstructible, and CopyAssignable requirements.

Date: 2017-03-03.22:19:58

[ Kona 2017-03-02 ]

Accepted as Immediate to resolve NB comment.

Date: 2017-03-01.06:47:48

[ Kona 2017-02-28: Jonathan provides updated wording as requested by LWG. ]

Date: 2017-03-01.06:47:48

Addresses US 153

istream_iterator default constructor requires a DefaultConstructible T.

Proposed change:

Add a new p1:

Requires: T is DefaultConstructible.

Previous resolution [SUPERSEDED]:

This wording is relative to N4618.

  1. Modify [istream.iterator.cons] as indicated:

    see below istream_iterator();
    

    -?- Requires: T is DefaultConstructible.

    -1- Effects: Constructs the end-of-stream iterator. If is_trivially_default_constructible_v<T> is true, then this constructor is a constexpr constructor.

    -2- Postconditions: in_stream == 0.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2017-03-05 23:46:08adminsetstatus: immediate -> wp
2017-03-03 22:19:58adminsetmessages: + msg9073
2017-03-03 22:19:58adminsetstatus: new -> immediate
2017-03-01 06:47:48adminsetmessages: + msg9020
2017-02-03 21:37:02adminsetmessages: + msg8869
2017-02-03 00:00:00admincreate