[libcxx-commits] [libcxx] [libc++] Optimize `to_chars` for bases 2, 8 and 16 (PR #223222)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 14 00:23:11 PDT 2026


frederick-vs-ja wrote:

> > Seems like a reasonable optimization, but
> > 
> > * As Zingam mentioned, some of those builtins might need feature-tests. `__builtin_bit_cast` is also more recent than `std::to_chars`.
> 
> Aren't builtins typically available to all standard modes? AFAIK you can use those internally to implement stuff for older standards. Apparently we have this internal function: __bit_cast that can be used in C++11 and newer.

I guess Jan intended to mean that `__builtin_bit_cast` (added in LLVM 9, via eee944e7f9e60df44714eb547d0b876ee5dc7290/https://reviews.llvm.org/D62825) was newer than the initial parts of `std::to_chars` (added in LLVM 7, via d27489645bb8829a952f79e3b211202844238391/https://reviews.llvm.org/D41458).

But I believe we can consider `__builtin_bit_cast` to be unconditionally available now.

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


More information about the libcxx-commits mailing list