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

[container.reqmts] Avoid dependency of size/max_size on distance(begin(), end()) #6826

Closed

Conversation

frederick-vs-ja
Copy link
Contributor

c.size() and c.max_size() should be always well-defined, and thus shouldn't be dependent on std::distance. Related to #6822.

@jwakely
Copy link
Member

jwakely commented Feb 26, 2024

I don't like this. "whenever well-defined" suggests that it's OK for standard containers to allow more elements than can be represented by their difference_type, which would be stupid. It makes things unnecessarily complicated for users, because they need to worry about that case and whether it's UB.

Why would we want to push that problem onto users, instead of saying implementations aren't allowed to be stupid?

@jensmaurer
Copy link
Member

This feels like a semantic change. Previously, there was a requirement that the result of std::distance can represent the container's size. Now, that requirement is gone.

-> not editorial

@jensmaurer jensmaurer closed this Feb 26, 2024
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 this pull request may close these issues.

None yet

3 participants