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

<map>, <unordered_map>: Allow MapLike<K, V&> again #3660

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

StephanTLavavej
Copy link
Member

One of the changes that I pushed to #2436 was damaging - while map-like types can't tolerate references as key types, using references as mapped types appears to be permitted (by the Standard, libstdc++, and libc++), and there are 4 projects across vcpkg and Real World Code that are doing this.

Fortunately, we can fix this before changes stop flowing into VS 2022 17.7 Preview 2, so users will never be affected. I'm removing my bad static_asserts, and adding test coverage to minimally verify that this scenario compiles.

(I suppose we could instead assert that the mapped types aren't function types or void types, but I'd rather just drop it entirely. Such usage is extremely unlikely and will still be rejected, just with lengthy diagnostics.)

@StephanTLavavej StephanTLavavej added bug Something isn't working high priority Important! labels Apr 18, 2023
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner April 18, 2023 19:41
@StephanTLavavej
Copy link
Member Author

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@cjdb
Copy link

cjdb commented Sep 6, 2024

using references as mapped types appears to be permitted (by the Standard

[associative.reqmts.general]/8 says that the rules applying to value_type instead apply to key_type and mapped_type for our map types. If references are allowed for mapped_type, doesn't that imply they're also allowed for key_type and other containers' value_type?

@CaseyCarter
Copy link
Member

I think the cross-references in [associative.reqmts.general] are swapped; it doesn't make sense to apply the value_type requirements from the allocator-aware requirements to key_type and mapped_type. cplusplus/draft#7249 tries to fix them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority Important!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants