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

Transparent comparators #150

Closed
Morwenn opened this issue Jul 19, 2019 · 2 comments
Closed

Transparent comparators #150

Morwenn opened this issue Jul 19, 2019 · 2 comments
Milestone

Comments

@Morwenn
Copy link
Owner

Morwenn commented Jul 19, 2019

It just occurred to me that many of the functions in the comparators module of the library are actually transparent function objects since they can compare instances of different types and use perfect forwarding. However they lack the is_transparent member types that allows some containers to detect that they are function objects.

Next task: check that they satisfy the transparent function object requirements, add the is_transparent member type accordingly, and add tests if it makes sense.

@Morwenn
Copy link
Owner Author

Morwenn commented Jul 23, 2019

I added is_transparent to partial/weak/total_less/greater in 158f721.

Next step is to check whether it is possible to do it in a sensible way for the other comparators, which might not be possible for the refined versions, but I have to check to make sure.

In the meantime, I might have to expose the name of the function objects because passing decltype(total_less) to std::set apparently doesn't work, and having to pass std::remove_cvref_t<decltype(total_less)> is not user friendly. I guess that I will travel the simple road and have names like total_less_t: it's discoverable, usable, and not that important in the grand scheme of things since it provides a feature that isn't used by the sorting library itself.

@Morwenn Morwenn added this to the 1.5.0 milestone Jul 25, 2019
@Morwenn
Copy link
Owner Author

Morwenn commented Jul 28, 2019

is_transparent was also added to non-refined versions of natural_less and case_insensitive_less, and I exposed the types of the basic versions of every comparator of the module. Moreover natural_less can now compare different collections as long as they have the similar element types.

@Morwenn Morwenn closed this as completed Jul 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant