[libcxx-commits] [libcxx] [libc++] Hoist <compare> outside the threads guard in <thread> (PR #202535)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 9 02:05:29 PDT 2026


ldionne wrote:

So, just to make sure we're on the same page, what you're advocating for is that we unconditionally include implementation-detail headers outside carve-outs and standard modes, and that we do that consistently. And then we'd only guard the actual parts of implementation-detail headers that don't work when a carve-out is active.

Just to clarify, let's take `<thread>` as an example. Before (let's assume this patch lands, which makes it consistent with what we do for all other headers):

```c++
// [thread.syn]
#  include <compare>

#  if _LIBCPP_HAS_THREADS

#    include <__thread/this_thread.h>
#    include <__thread/thread.h>

#    if _LIBCPP_STD_VER >= 20
#      include <__thread/jthread.h>
#    endif

#    if _LIBCPP_STD_VER >= 23
#      include <__thread/formatter.h>
#    endif

#    include <version>
#  endif // _LIBCPP_HAS_THREADS
```

What is your target? One possibility:

```c++
// note: no more _LIBCPP_HAS_THREADS check here

#    include <__thread/this_thread.h>
#    include <__thread/thread.h>

#    if _LIBCPP_STD_VER >= 20 // do you want this here or inside `jthread.h`?
#      include <__thread/jthread.h>
#    endif

#    if _LIBCPP_STD_VER >= 23
#      include <__thread/formatter.h>
#    endif

#    include <version>
```

https://github.com/llvm/llvm-project/pull/202535


More information about the libcxx-commits mailing list