Implements part of P1614R2 "The Mothership has Landed"
Depends on D150188
Paths
| Differential D132268
[libc++][spaceship] Implement `operator<=>` for `vector` ClosedPublic Authored by H-G-Hristov on Aug 19 2022, 4:52 PM.
Details
Summary Implements part of P1614R2 "The Mothership has Landed" Depends on D150188
Diff Detail
Event Timelineavogelsgesang added a parent revision: D131395: [libc++] Implement `lexicographical_compare_three_way`.Aug 19 2022, 4:53 PM Comment Actions needs to be adjusted to use the still-to-be-introduced test utilities from https://reviews.llvm.org/D132312 is done avogelsgesang edited parent revisions, added: D132312: [libc++][spaceship] Implement `operator<=>` for `list`; removed: D131395: [libc++] Implement `lexicographical_compare_three_way`.Nov 20 2022, 6:49 PM Comment Actions Incorporate feedback received for similar review (list instead of vector; https://reviews.llvm.org/D132312) Comment Actions I had a quick look and no real comments. Can you fix the CI? I prefer to review the changes after a CI run. Comment Actions @H-G-Hristov unfortunately, I don't know when I will find time to come back to this (and https://reviews.llvm.org/D132265). Feel free to take this over, if you are blocked by it Comment Actions
Thank you. I'll probably take them over then if you haven't finished them before I get the time. Comment Actions
H-G-Hristov added a child revision: D146094: [libc++][spaceship] Implement `operator<=>` for `stack`.Apr 29 2023, 10:04 AM H-G-Hristov added inline comments.
Comment Actions @Mordante Thank you for the review.
Comment Actions Looks basically good, but I'd like to understand the __debug_three_way_comp change before approving.
Comment Actions @philnik Thank you for the review!
This change was proposed by avogelsang above actually, as without it the tests of vector<bool> build fails with:
Comment Actions
Ah OK. It's for iterators not returning an lvalue reference. In this case I think it would be better to forward the arguments, since that will definitely be correct. Comment Actions
Sorry, I think I confused you. The actual problem is in the compare function, the last parameter of: : note: candidate template ignored: substitution failure [with _InputIterator1 = std::__bit_iterator<std::vector<bool>, true, 0>, _InputIterator2 = std::__bit_iterator<std::vector<bool>, true, 0>, _Cmp = std::__debug_three_way_comp<std::strong_ordering (*)(const bool &, const bool &)>]: no matching function for call to object of type 'std::__debug_three_way_comp<std::strong_ordering (*)(const bool &, const bool &)>' _LIBCPP_HIDE_FROM_ABI constexpr auto __lexicographical_compare_three_way_fast_path( Comment Actions
Ah OK. It's for iterators not returning an lvalue reference. In this case I think it would be better to forward the arguments, since that will definitely be correct.
IIUC the problem is that __bit_iterator::operator* returns an object instead of a reference, which can't bind to an lvalue reference. If we use perfect forwarding that should fix the problem? Comment Actions
Could you please confirm if I understand correctly: I am supposed to perfectly forward the arguments to std::__lexicographical_compare_three_way_fast_path something like that: return std::__lexicographical_compare_three_way_fast_path( std::forward<_InputIterator1>(__first1), std::forward<_InputIterator1>(__last1), std::forward<_InputIterator2>(__first2), std::forward<_InputIterator2>(__last2), __wrapped_comp_ref); No, that still wasn't enough. The compilation fails without changes to LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __x, _Up& __y)'s signature. There was ways an issue with the 5th parameter (for the record I tried forward, move). Comment Actions
I meant that you should perfect-forward the arguments in __debug_three_way_comp::operator(). i.e. std::forward the arguments to __comp_. The std::forwards you are currently doing in the calls are essentially just std::moves, since the arguments are prvalue types. Comment Actions A few more comments. I want to have a short look at the final version especially the answers to some of @philnik's remarks.
Comment Actions @Mordante Thank you for the suggestions!
This revision is now accepted and ready to land.May 22 2023, 10:36 AM Comment Actions
Thank you for the review. This one now passes but it still needs the stacked change to be completed/approved. Closed by commit rG55ec808a8897: [libc++][spaceship] Implement `operator<=>` for `vector` (authored by Zingam). · Explain WhyJun 9 2023, 8:53 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 520053 libcxx/docs/Status/SpaceshipProjects.csv
libcxx/include/__algorithm/lexicographical_compare_three_way.h
libcxx/include/__algorithm/three_way_comp_ref_type.h
libcxx/include/vector
libcxx/test/std/containers/sequences/vector.bool/compare.three_way.pass.cpp
libcxx/test/std/containers/sequences/vector/compare.three_way.pass.cpp
libcxx/test/support/test_container_comparisons.h
|
Did you validate this output looks good?