diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-11-28 16:32:24 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-11-28 16:33:33 +0100 |
commit | 7393fa8b1d21eeeb37e59ff8efaebf178fd891e5 (patch) | |
tree | e9783e8c9b7f6b196d9548b10793d0d9c88f83db /gcc | |
parent | 7a66c4909fd175ba429f39a3ca30be39ea02ae64 (diff) | |
download | gcc-7393fa8b1d21eeeb37e59ff8efaebf178fd891e5.zip gcc-7393fa8b1d21eeeb37e59ff8efaebf178fd891e5.tar.gz gcc-7393fa8b1d21eeeb37e59ff8efaebf178fd891e5.tar.bz2 |
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.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions