[libcxx-commits] [PATCH] D130838: [libc++] Implement `operator<=>` for `unique_ptr`
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Aug 6 06:04:10 PDT 2022
Mordante accepted this revision.
Mordante added a comment.
This revision is now accepted and ready to land.
LGTM, thanks!
I'll commit this on your behalf.
================
Comment at: libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.special/cmp.pass.cpp:72
+#if TEST_STD_VER > 17
+ AssertOrderReturn<std::strong_ordering, std::unique_ptr<int>>();
+#endif
----------------
avogelsgesang wrote:
> Mordante wrote:
> > Can you also test with the other two comparison categories? Not 100% sure it's even possible.
> I don't understand.
>
> `unique_ptr <=> unique_ptr` is specified to return `std::strong_ordering`. If I added, e.g.,
>
> > AssertOrderReturn<std::weak_ordering, std::unique_ptr<int>>();
>
> this test would fail because the result of `unique_ptr <=> unique_ptr` is strong_ordering, not weak_ordering
After I wrote the question I wondered whether it would be possible at all. The odd part is that `std::shared_ptr` uses `strong_ordering`, but `unique_ptr` deduces the ordering. But it seems it indeed should always be `strong_ordering`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130838/new/
https://reviews.llvm.org/D130838
More information about the libcxx-commits
mailing list