libstdc++: Add std::bit_cast for C++20 [PR 93121]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 3 Dec 2020 19:17:13 +0000 (19:17 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 3 Dec 2020 19:17:13 +0000 (19:17 +0000)
commit9e433b3461ab64b38350817392a77efb67bb78b4
treee7120a6f2ad5b0176b2325ceb078ef977673379c
parentadbeeb198a2a00812a5cd2ff0a38d6243a590dd0
libstdc++: Add std::bit_cast for C++20 [PR 93121]

Thanks to Jakub's addition of the built-in, we can add this to the
library now. The compiler tests for the built-in are quite extensive,
including verifying the constraints, so this only adds minimal tests to
the library testsuite.

This doesn't add a new _GLIBCXX_HAVE_BUILTIN_BIT_CAST because using
__has_builtin(__builtin_bit_cast) works for GCC and versions of Clang
that provide the built-in.

libstdc++-v3/ChangeLog:

PR libstdc++/93121
* include/std/bit (__cpp_lib_bit_cast, bit_cast): Define.
* include/std/version (__cpp_lib_bit_cast): Define.
* testsuite/26_numerics/bit/bit.cast/bit_cast.cc: New test.
* testsuite/26_numerics/bit/bit.cast/version.cc: New test.
libstdc++-v3/include/std/bit
libstdc++-v3/include/std/version
libstdc++-v3/testsuite/26_numerics/bit/bit.cast/bit_cast.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/bit/bit.cast/version.cc [new file with mode: 0644]