-
- Downloads
libstdc++: Implement std::byteswap for C++23
This patch attempts to implement P1272R4 (except for the std::bit_cast changes in there which seem quite unrelated to this and will need to be fixed on the compiler side). While at least for GCC __builtin_bswap{16,32,64,128} should work fine in constant expressions, I wonder about other compilers, so I'm using a fallback implementation for constexpr evaluation always. If you think that is unnecessary, I can drop the __cpp_if_consteval >= 202106L && if !consteval { and } and reformat. The fallback implementation is an attempt to make it work even for integral types that don't have number of bytes divisible by 2 or when __CHAR_BIT__ is e.g. 16. 2021-11-28 Jakub Jelinek <jakub@redhat.com> * include/std/bit (__cpp_lib_byteswap, byteswap): Define. * include/std/version (__cpp_lib_byteswap): Define. * testsuite/26_numerics/bit/bit.byteswap/byteswap.cc: New test. * testsuite/26_numerics/bit/bit.byteswap/version.cc: New test.
Showing
- libstdc++-v3/include/std/bit 49 additions, 0 deletionslibstdc++-v3/include/std/bit
- libstdc++-v3/include/std/version 1 addition, 0 deletionslibstdc++-v3/include/std/version
- libstdc++-v3/testsuite/26_numerics/bit/bit.byteswap/byteswap.cc 112 additions, 0 deletions...c++-v3/testsuite/26_numerics/bit/bit.byteswap/byteswap.cc
- libstdc++-v3/testsuite/26_numerics/bit/bit.byteswap/version.cc 27 additions, 0 deletions...dc++-v3/testsuite/26_numerics/bit/bit.byteswap/version.cc
Loading
Please register or sign in to comment