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.

### 2793. Awkward conflation of trivial special members of `istream_iterator`

Section: 23.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`. If `T` has a trivial copy constructor, then this constructor shall be a trivial copy constructor. If `T` has a constexpr copy constructor, then this constructor shall be `constexpr`.

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.

Suggested resolution:

Revise p7 as:

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

> 1. Change 23.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 type `is_trivially_constructible_v<T> == true`, then this constructor shall be a is a trivial, `constexpr` constructor.

> 2. Change 23.6.2.2 [istream.iterator.cons] p5 as indicated:

>    >     istream_iterator(const istream_iterator& x) = default;

>    > > -5- Effects: Constructs a copy of `x`. If `T` is a literal type `is_trivially_copyable_v<T> == true`, then this constructor shall be is a trivial copy constructor.

> 3. Change 23.6.2.2 [istream.iterator.cons] p7 as indicated:

>    >     ~istream_iterator() = default;

>    > > -7- Effects: The iterator is destroyed. If `T` is a literal type `is_trivially_destructible_v<T> == true`, then this destructor shall be is a trivial destructor.

[Issues Telecon 16-Dec-2016]

Resolved by the adoption of P0503R0

Proposed resolution:

Resolve by accepting the wording suggested by P0503R0.