[libcxx-commits] [PATCH] D92190: [libc++] fix std::sort(T**, T**)
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 4 15:13:19 PST 2020
Quuxplusone added a comment.
Aw, I wish I had seen this to bikeshed over it — it's relevant to my interests! (Finishing P0879 constexpr algorithms which includes `sort`; the nightmare minefield that is comparing pointers https://quuxplusone.github.io/blog/2019/01/20/std-less-nightmare/)
- Casting `T**` to `any-kind-of-int*` isn't something you can do constexprly, is it?
- Does this `sort` overload exist //purely// to avoid instantiating `std::less<T*>`? why is that so important? (`git blame` offers no help; this codepath dates back to Howard's initial import.)
- Could this `sort` overload simply delegate to `_VSTD::sort(first, last, __less<void*>())`, to avoid the constexpr-unfriendly part? (That is, don't type-pun the actual elements; force an implicit conversion to `void*` before each comparison.)
- If we did that, of course we'd want to add `void*` to the list of types for which `sort`'s helper functions are explicitly instantiated in "algorithm.cpp". Hmm, I wonder if `char8_t`, `char16_t`, etc. should already be there...
Anyway, no action required AFAIconcerned; I'm just thinking out loud and trying //not// to go too far down the rabbit-hole yet. This will clearly be revisited for real at some point, as part of P0879 constexpr sort.
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
More information about the libcxx-commits