This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.

3259. The definition of constexpr iterators should be adjusted

Section: 25.3.1 [iterator.requirements.general] Status: C++20 Submitter: Daniel Krügler Opened: 2019-08-18 Last modified: 2021-02-25

Priority: 0

View all other issues in [iterator.requirements.general].

View all issues with C++20 status.

Discussion:

The current definition of constexpr iterators is specified in 25.3.1 [iterator.requirements.general] p16 as follows:

Iterators are called constexpr iterators if all operations provided to meet iterator category requirements are constexpr functions, except for

  1. (16.1) — a pseudo-destructor call (7.5.5.5 [expr.prim.id.dtor]), and

  2. (16.2) — the construction of an iterator with a singular value.

With the acceptance of some proposals during the Cologne 2019 meeting, these additional requirements become mostly obsolete, as it had already been pointed out during that meeting:

With the acceptance of P0784R7, destructors can be declared constexpr and it is possible to perform a pseudo-destructor call within a constant expression, so bullet (16.1) is no longer a necessary requirement.

With the acceptance of P1331R2, trivial default initialization in constexpr contexts is now possible, and there is no longer a requirement to initialize all sub-objects of a class object within a constant expression.

It seems to me that we should simply strike the above two constraining requirements of the definition of constexpr iterators for C++20.

[2019-09-14 Issue Prioritization]

Status to Tentatively Ready and priority to 0 after five positive votes on the reflector.

Proposed resolution:

This wording is relative to N4830.

  1. Modify 25.3.1 [iterator.requirements.general] as indicated:

    -16- Iterators are called constexpr iterators if all operations provided to meet iterator category requirements are constexpr functions., except for

    1. (16.1) — a pseudo-destructor call (7.5.5.5 [expr.prim.id.dtor]), and

    2. (16.2) — the construction of an iterator with a singular value.