You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to replace my use of std::nth_element with miniselect's implementation of Andrei Alexandrescu's adaptive quickselect, but I ran into an issue while doing so: it seems that one of the median_index overloads does not consistently use the given comparator to compare elements (lines marked with HERE):
I stumbled upon this issue while trying to sort with a custom predicate a collection of a type that doesn't have comparison operators, so I fortunately got into a compile-time error, but I believe that it can result into more subtle runtime errors too when the types to sort do implement comparison operators.
Anyway, thanks again for this library, I'm glad to see selection algorithms getting some love 😄
The text was updated successfully, but these errors were encountered:
0.4.0 fixed, thank you. Everybody should use this version, my bad I didn't notice and somehow testing did not catch the failure -- in one test I was comparing pointers and all sanitizers were good :(
No problem, I plan to use the algorithm to replace libc++'s nth_element in one of my rather well-tested projects - I only noticed recently that it was O(n²) -, so I will tell you if I find anything else. Thanks for the quick fix 🙂
I was trying to replace my use of
std::nth_element
with miniselect's implementation of Andrei Alexandrescu's adaptive quickselect, but I ran into an issue while doing so: it seems that one of themedian_index
overloads does not consistently use the given comparator to compare elements (lines marked withHERE
):I stumbled upon this issue while trying to sort with a custom predicate a collection of a type that doesn't have comparison operators, so I fortunately got into a compile-time error, but I believe that it can result into more subtle runtime errors too when the types to sort do implement comparison operators.
Anyway, thanks again for this library, I'm glad to see selection algorithms getting some love 😄
The text was updated successfully, but these errors were encountered: