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 /libstdc++-v3/include/std/version | |
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 'libstdc++-v3/include/std/version')
-rw-r--r-- | libstdc++-v3/include/std/version | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index fd7e125..2d4e9bf 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -294,6 +294,7 @@ #if __cplusplus > 202002L // c++2b #define __cpp_lib_adaptor_iterator_pair_constructor 202106L +#define __cpp_lib_byteswap 202110L #define __cpp_lib_invoke_r 202106L #define __cpp_lib_is_scoped_enum 202011L #if __cpp_lib_concepts |