[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:49:49 PDT 2026


================
@@ -37,22 +36,6 @@ void format_tests(TestFunction check, ExceptionTest check_exception) {
   check(SV("0****"), SV("{:*<{}}"), input, 5);
   check(SV("__0__"), SV("{:_^{}}"), input, 5);
   check(SV("####0"), SV("{:#>{}}"), input, 5);
----------------
ldionne wrote:

I think this test should be libc++ specific, since nothing guarantees that a value-initialized thread id is `0`. And if we make this more libc++ specific, I think we should add a test where we:
1. Get the current thread's ID
2. Print it
3. Parse it again as a number
4. Make sure it's the same number

This should be robust and it tests more than just `0`.

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


More information about the libcxx-commits mailing list