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

[flat.map.defn,flat.multimap.defn] Deduction guide needs to default Allocator to be useful LWG3786 #5800

Closed
JohelEGP opened this issue Aug 29, 2022 · 6 comments · Fixed by #6116
Labels
lwg Issue must be reviewed by LWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.

Comments

@JohelEGP
Copy link
Contributor

Is this right? What does it mean that the previous template parameter Compare is defaulted, but Allocator isn't, even though both corresponding function parameters are defaulted? Seems like you can't get this to work without defaulting this Allocator: https://godbolt.org/z/fYesrsbMz.

           class Allocator = allocator<ranges::range_value_t<R>>>
           class Allocator = allocator<@\exposid{range-mapped-type}@<R>>>

I think both suggestions fulfill the corresponding Constraints element.

           class Allocator = allocator<void>>

Originally posted by @JohelEGP in #5626 (comment)

See also https://github.com/cplusplus/draft/pull/5626/files#r922820452.

@cpplearner
Copy link
Contributor

The affected deduction guides are

draft/source/containers.tex

Lines 14934 to 14937 in bc6d64c

template<ranges::@\libconcept{input_range}@ R, class Compare = less<@\exposid{range-key-type}@<R>>,
class Allocator>
flat_map(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
-> flat_map<@\exposid{range-key-type}@<R>, @\exposid{range-mapped-type}@<R>, Compare>;

draft/source/containers.tex

Lines 16039 to 16042 in bc6d64c

template<ranges::@\libconcept{input_range}@ R, class Compare = less<@\exposid{range-key-type}@<R>>,
class Allocator>
flat_multimap(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
-> flat_multimap<@\exposid{range-key-type}@<R>, @\exposid{range-mapped-type}@<R>, Compare>;

In these deduction guides, there's no Allocator on the right of ->, which means the Allocator does not affect the result of deduction. So IIUC it doesn't matter what the default is, as long as there is a default.

@jensmaurer jensmaurer added the lwg Issue must be reviewed by LWG. label Aug 30, 2022
@jensmaurer
Copy link
Member

Something is strange here, but the fix doesn't seem to be editorially-obvious. Maybe we want to pass the Allocator parameter to the vector containers that are inside the flat_map?

@jwakely , this looks like a library issue to me.

@jwakely
Copy link
Member

jwakely commented Sep 24, 2022

@jwakely , this looks like a library issue to me.

Yes, I agree. Please submit one, @JohelEGP

@jensmaurer jensmaurer added the not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. label Sep 24, 2022
@JohelEGP JohelEGP changed the title [flat.map.defn,flat.multimap.defn] Deduction guide needs to default Allocator to be useful [flat.map.defn,flat.multimap.defn] Deduction guide needs to default Allocator to be useful LWG3786 Sep 25, 2022
@JohelEGP
Copy link
Contributor Author

@jwakely
Copy link
Member

jwakely commented Sep 25, 2022

Thanks!

@JohelEGP
Copy link
Contributor Author

Status: WP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lwg Issue must be reviewed by LWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants