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

[defns.projection] The example isn't demonstrating the effects of customized projection #6462

Open
frederick-vs-ja opened this issue Aug 18, 2023 · 0 comments

Comments

@frederick-vs-ja
Copy link
Contributor

In the current example

std::pair<int, std::string_view> pairs[] = {{2, "foo"}, {1, "bar"}, {0, "baz"}};
std::ranges::sort(pairs, std::ranges::less{}, [](auto const& p) { return p.first; });

the result of sorting is same of that using default std::identity.
It might make more sense to use [](auto const& p) { return p.second; } as the projection.

Moreover, std::format("{}", pairs) (after sorting) gives [(0, "baz"), (1, "bar"), (2, "foo")] or [(1, "bar"), (0, "baz"), (2, "foo")] since C++23. Should we change the result in the example to match std::format?

@frederick-vs-ja frederick-vs-ja changed the title [defns.projection] The example isn't demostrating the effects of customized projection [defns.projection] The example isn't demonstrating the effects of customized projection Aug 18, 2023
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

No branches or pull requests

1 participant