[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
Mon Mar 9 07:36:28 PDT 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>;
+
+ static const size_t __buffer_size = numeric_limits<__int_type>::digits10 + 1;
+ char __buffer[__buffer_size];
+ auto __ret =
----------------
ldionne wrote:
> Where? I definitely didn't mean to imply that.
The PR title says: `Use std::to_chars to format`. I interpreted "to format" as meaning `std::format` specifically. But I understand the patch and the intent now, all good.
https://github.com/llvm/llvm-project/pull/181624
More information about the libcxx-commits
mailing list