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

The Standard should defend container constructors from bad CTAD #4261

Closed
StephanTLavavej opened this issue Dec 14, 2023 · 2 comments
Closed
Labels
duplicate This issue or pull request already exists LWG issue needed A wording defect that should be submitted to LWG as a new issue

Comments

@StephanTLavavej
Copy link
Member

From #4254:

@StephanTLavavej

Found by the upcoming libcxx update, where they test CTAD for (Iter, Iter, BadAlloc) and expect it to SFINAE away.

(The explicit deduction guides are already constrained to take only things that qualify as allocators. The issue is that every constructor generates an implicit guide, and those can lead to the container being instantiated with a BadAlloc unless we guard against that.)

It's actually unclear to me whether this is guaranteed by the Standard, but the defense is simple and we already do this in basic_string.

@CaseyCarter

It's not guaranteed but IMO it should be. The Standard tells us to do so explicitly for basic_string.

The Standard has wording for deduction guides but not for constructors. This is slightly confusing since pre-Standard language in WG21 used "implicit" and "explicit" deduction guides to distinguish between the function templates derived from constructors for use in CTAD and those derived from deduction guides.

We ought to file an LWG issue.

Note that this goes beyond the sequence container constructors with (Iter, Iter, BadAlloc); there are also scenarios with the associative containers found by libcxx that I haven't yet fixed, and presumably others.

@StephanTLavavej StephanTLavavej added the LWG issue needed A wording defect that should be submitted to LWG as a new issue label Dec 14, 2023
@frederick-vs-ja
Copy link
Contributor

This issue seems to supersede #4060 (or be its duplicate).

@CaseyCarter
Copy link
Member

Yeah, let's close this as a duplicate of #4060 (which has more information).

@CaseyCarter CaseyCarter added the duplicate This issue or pull request already exists label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists LWG issue needed A wording defect that should be submitted to LWG as a new issue
Projects
None yet
Development

No branches or pull requests

3 participants