This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.
DefaultConstructible
requirement for istream_iterator
default constructorSection: 24.6.2.2 [istream.iterator.cons] Status: C++17 Submitter: United States Opened: 2017-02-03 Last modified: 2020-09-06
Priority: Not Prioritized
View all other issues in [istream.iterator.cons].
View all issues with C++17 status.
Discussion:
Addresses US 153
istream_iterator
default constructor requires a DefaultConstructible T
.
Proposed change:
Add a new p1:
Requires:
T
isDefaultConstructible
.
Previous resolution [SUPERSEDED]:
This wording is relative to N4618.
Modify 24.6.2.2 [istream.iterator.cons] as indicated:
see below istream_iterator();-?- Requires:
-1- Effects: Constructs the end-of-stream iterator. IfT
isDefaultConstructible
.is_trivially_default_constructible_v<T>
istrue
, then this constructor is aconstexpr
constructor. -2- Postconditions:in_stream == 0
.
[Kona 2017-02-28: Jonathan provides updated wording as requested by LWG.]
[Kona 2017-03-02]
Accepted as Immediate to resolve NB comment.
Proposed resolution:
This wording is relative to N4618.
Modify 24.6.2 [istream.iterator] as indicated:
-1- The class template
istream_iterator
is an input iterator (24.2.3) that reads (usingoperator>>
) 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 ofT
. If the iterator fails to read and store a value ofT
(fail()
on the stream returnstrue
), the iterator becomes equal to the end-of-stream iterator value. The constructor with no argumentsistream_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 ofoperator*
on an end-of-stream iterator is not defined. For any other iterator value aconst T&
is returned. The result ofoperator->
on an end-of-stream iterator is not defined. For any other iterator value aconst T*
is returned. The behavior of a program that appliesoperator++()
to an end-of-stream iterator is undefined. It is impossible to store things into istream iterators. The typeT
shall meet theDefaultConstructible
,CopyConstructible
, andCopyAssignable
requirements.