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] s/compare/key_comp()/ #5924

Closed
wants to merge 1 commit into from

Conversation

Quuxplusone
Copy link
Contributor

It looks to me as if the identifier compare is not defined in these scopes.

(I also think key_equiv should be replaced throughout with @\exposid{key-equiv}@, but exposid markup is an orthogonal issue with discussion in #5812. I also think the key_equiv(key_compare) ctor should be explicit, but that's purely stylistic AFAICT.)

@JohelEGP
Copy link
Contributor

Is [flat.map] right? flat_map does have a compare non-static data member. If you expand the context of the first change towards the top, you can even see
1667139981

@Quuxplusone
Copy link
Contributor Author

Is [flat.map] right? flat_map does have a compare non-static data member.

Oh, bother. This whole thing might just be a subset of the "need to \exposid more things" issue, then. I think this PR is still a minor improvement in clarity, but maybe it's not a mistake as-written. Feel free to close this PR if that's the general consensus.

I also just noticed that https://eel.is/c++draft/flat.map#overview-10 arguably should say "range that is not sorted with respect to value_comp()" instead of "with respect to key_­comp()", but don't plan to submit a PR for that.

@JohelEGP
Copy link
Contributor

I also just noticed that https://eel.is/c++draft/flat.map#overview-10 arguably should say "range that is not sorted with respect to value_comp()" instead of "with respect to key_­comp()", but don't plan to submit a PR for that.

IIRC, only the keys are required to be sorted.

@Quuxplusone
Copy link
Contributor Author

I also just noticed that https://eel.is/c++draft/flat.map#overview-10 arguably should say "range that is not sorted with respect to value_comp()" instead of "with respect to key_­comp()", but don't plan to submit a PR for that.

IIRC, only the keys are required to be sorted.

Yes, but in

    template<class InputIterator>
      flat_map(sorted_unique_t s, InputIterator first, InputIterator last,
               const key_compare& comp = key_compare())

the range expressed by [first, last) is a range of value_type (i.e. pair<Key,T>) that must be sorted w.r.t. value_comp(). key_comp() will be something like less<Key>, which doesn't take pairs at all. But I think you've just found another typo, namely "...a container, containers, or range that is not sorted..." I don't think there's any situation where more than one container needs to be sorted by anything. Anyway, my overall sense is that this intro wording is vague and messy and that's exactly why I'm not going to tackle submitting a PR for it. :)

Orthogonally yet again, I notice that the from_range_t overloads do not support e.g. mySortedVector | views::unique | ranges::to<flat_set<int>>(sorted_unique). But I assume that's at least semi-intentional and thus LEWG territory.

@Quuxplusone Quuxplusone closed this Nov 1, 2022
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

2 participants