mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-16 20:37:03 +03:00
C.183: Mention bit_cast as a C++20+ solution (#2293)
* C.183: Mention bit_cast as a C++20+ solution * Remove last line The change looks good, just removing the last line as it's more documentation than guidance --------- Co-authored-by: Herb Sutter <herb.sutter@gmail.com>
This commit is contained in:
@@ -9032,7 +9032,9 @@ but at least we can see that something tricky is going on.)
|
||||
Unfortunately, `union`s are commonly used for type punning.
|
||||
We don't consider "sometimes, it works as expected" a conclusive argument.
|
||||
|
||||
C++17 introduced a distinct type `std::byte` to facilitate operations on raw object representation. Use that type instead of `unsigned char` or `char` for these operations.
|
||||
Modern C++ introduced `std::byte` (C++17) and `std::bit_cast` (C++20) to facilitate operations on raw object representations.
|
||||
Use `reinterpret_cast` along with `std::byte` instead of `unsigned char` or `char` for these operations.
|
||||
|
||||
|
||||
##### Enforcement
|
||||
|
||||
|
||||
Reference in New Issue
Block a user