-
Notifications
You must be signed in to change notification settings - Fork 11
Refactor threeway compare operator #71
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
Conversation
|
Thank you for your contribution! I will review this later! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to approve this PR -- I'll trust you to make any additional changes as you see fit and merging. Good work actually fixing this since it was just wrong. Welcome @20162026 and thanks for your contribution!
|
Just noticed that my suggestion will not properly handle unorderable values eg. nan("") == nan(""). |
|
I think the pre-conditions here mean that if you have nans you're in violation and it's UB |
|
I understand precondition as: T models three_way_comparable OR (< is defined for values of type T and < is a total ordering relationship) nan (float/double) is three_way_comparable with std::partial_ordering, furthermore std::vector nan compare results in std::partial_ordering::unordered |
Can you list out cases that fails with the original implementation? |
almost all of the issues I could think of are already covered by tests.
|
Oh I didn't realize you added test as well!! This is fantastic! |
wusatosi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution. As I understand you still have some progress to make, feel free to @wusatosi to notify me once you're done, I can also approve so you can do that in a separate PR.
Again thank you so much for your contribution!
|
@wusatosi Im done with the changes |
|
|
||
| template <class T> | ||
| concept lessthan_comparable = | ||
| beman::details::inplace_vector::lessthan_comparable<T>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It strikes me that the namespace is backwards here -- should be beman::inplace_vector::detail -- but that's an existing issue of course. And maybe something we don't address clearly in the standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be wrong here, but beman::inplace_vector clashes with the inplace_vector struct under the beman namespace.
wusatosi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
reimplement
<=>as the previous implementation was questionable and failed in some cases.based on rules described at: https://en.cppreference.com/w/cpp/container/inplace_vector/operator_cmp