istream_iterator
Section: 24.6.2.2 [istream.iterator.cons] Status: C++17 Submitter: Erich Keane Opened: 2016-11-09 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 GB 68, US 154, US 155
The term 'literal type' is dangerous and misleading, as text using this term really wants to require that a constexpr constructor/initialization is called with a constant expression, but does not actually tie the selected constructor to the type being 'literal'. Suggested resolution: Verify the uses of the term in the Core and Library specifications and replace with something more precise where appropriate. The conflation of trivial copy constructor and literal type is awkward. Not all literal types have trivial copy constructors, and not all types with trivial copy constructors are literal. Suggested resolution: Revise p5 as:Effects: Constructs a copy of
x
. IfT
has a trivial copy constructor, then this constructor shall be a trivial copy constructor. IfT
has a constexpr copy constructor, then this constructor shall beconstexpr
.
The requirement that the destructor is trivial if T
is a
literal type should be generalized to any type T
with a
trivial destructor — this encompasses all literal types,
as they are required to have a trivial destructor.
Effects: The iterator is destroyed. If
T
has a trivial destructor, then this destructor shall be a trivial destructor.
Previous resolution [SUPERSEDED]:
This wording is relative to N4606.
Change 24.6.2.2 [istream.iterator.cons] p1 as indicated:
see below istream_iterator();-1- Effects: Constructs the end-of-stream iterator. If
T
is a literal typeis_trivially_constructible_v<T> == true
, then this constructorshall be ais a trivial,constexpr
constructor.Change 24.6.2.2 [istream.iterator.cons] p5 as indicated:
istream_iterator(const istream_iterator& x) = default;-5- Effects: Constructs a copy of
x
. IfT
is a literal typeis_trivially_copyable_v<T> == true
, then this constructorshall beis a trivial copy constructor.Change 24.6.2.2 [istream.iterator.cons] p7 as indicated:
~istream_iterator() = default;-7- Effects: The iterator is destroyed. If
T
is a literal typeis_trivially_destructible_v<T> == true
, then this destructorshall beis a trivial destructor.
[Issues Telecon 16-Dec-2016]
Resolved by the adoption of P0503R0
Proposed resolution:
Resolve by accepting the wording suggested by P0503R0.