[libcxx-commits] [PATCH] D131362: [libc++] Implement `operator<=> for `thread::id`

Adrian Vogelsgesang via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Aug 7 09:48:01 PDT 2022


avogelsgesang created this revision.
avogelsgesang added reviewers: ldionne, Mordante, philnik, mumbleskates.
Herald added a project: All.
avogelsgesang requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

According to the standard, the `operator<=>` should be a free-standing
function instead of a hidden friend. However, the existing comparison
operators are also implemented as hidden friends (in contradiction to
the standard). Hence, this commit follows the prior art and also
implements `operator<=>` as hidden friend.

The new `operator<=>` is mapped onto the existing functions
`__libcpp_thread_id_equal` and `__libcpp_thread_id_less`. Introducing a
new `__libcpp_thread_id_compare_three_way` might lead to more efficient
code. Given that we can still introduce `__libcpp_thread_id_compare_three_way`
later, for this commit I opted to not break ABI. If requested, I will
add `__libcpp_thread_id_compare_three_way` in a follow-up commit.

Implements part of P1614R2 "The Mothership has Landed"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131362

Files:
  libcxx/docs/Status/SpaceshipProjects.csv
  libcxx/include/__threading_support
  libcxx/include/thread
  libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/cmp.pass.cpp
  libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp
  libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131362.450644.patch
Type: text/x-patch
Size: 9624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220807/776735b6/attachment.bin>


More information about the libcxx-commits mailing list