Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify that "constexpr iterator" is a requirement to be met #6792

Closed
Dani-Hub opened this issue Feb 4, 2024 · 0 comments · Fixed by #6793
Closed

Clarify that "constexpr iterator" is a requirement to be met #6792

Dani-Hub opened this issue Feb 4, 2024 · 0 comments · Fixed by #6793

Comments

@Dani-Hub
Copy link
Member

Dani-Hub commented Feb 4, 2024

The term constexpr iterator is defined in [iterator.requirements.general] as follows:

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

[Note 3: For example, the types "pointer to int" and reverse_iterator<int*> are constexpr iterators. - end note]

The particular form of this definition using the term "called" is untypical for introducing a requirement and has let to the interpretation in the proposed wording of LWG 4038 that when we require a type to meet the requirement of a constexpr iterator we should impose an "is a constexpr iterator" requirement.

This deviates from all existing places where we impose the form "meets the constexpr iterator requirements" instead ([string.view.iterators] p1, [basic.string.general] p5, [container.opt.reqmts] p1, [array.overview] p5, [vector.overview] p3).

Note that the term "meets the XX requirements" is not restricted to the Cpp17YY requirements, we use it elsewhere too, e.g. when we say that a type meets the character traits requirements ([char.traits]), the allocator-aware container requirements ([container.alloc.reqmts), or the layout mappings requirements ([mdspan.layout.policy.reqmts]), so this change would not be conflicting with existing style forms.

To make the status quo clearer this issue suggests to reword [iterator.requirements.general] to be a requirement. The alternative would be to change all currently referencing places to say "is a constexpr iterator" instead. Personally I prefer the notion of "meets the XX requirements" in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants