[libcxx-commits] [libcxx] [libc++] Use std::to_chars to format thread::id and canonicalize the representation across platforms (PR #181624)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 6 09:59:28 PST 2026
================
@@ -147,10 +147,15 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) {
// use a temporary stream instead and just output the thread
// id representation as a string.
- basic_ostringstream<_CharT, _Traits> __sstr;
- __sstr.imbue(locale::classic());
- __sstr << __id.__id_;
- return __os << __sstr.str();
+ using __int_type = __conditional_t<is_pointer<__libcpp_thread_id>::value, uintptr_t, __libcpp_thread_id>;
----------------
ldionne wrote:
There's an assumption that `__libcpp_thread_id` is integral if it's not a pointer. Let's `static_assert` that?
https://github.com/llvm/llvm-project/pull/181624
More information about the libcxx-commits
mailing list