Skip to content

Conversation

@ZERICO2005
Copy link
Contributor

C++20 <bit> provides std::bit_cast, which allows for cleaner type punning. I have not implemented popcount, rotr, countl_zero, and others for the header yet.

int32_t y = *reinterpret_cast<int32_t*>(&x);
int32_t z = std::bit_cast<int32_t>(x);

The compiler supports __is_trivial __is_trivially_copyable __is_standard_layout __is_pod __is_empty __is_polymorphic __is_abstract, so I added them to <type_traits>. In addition to is_compound, is_scalar, and is_object. I also added some tests to type_traits.cpp for is_signed and is_unsigned.

Lastly, since noexcept isn't a keyword in C++98, I fixed the definition of __NOEXCEPT for std=c++98 and std=gnu++98.

@adriweb adriweb merged commit bbb2b81 into CE-Programming:master Feb 2, 2025
@ZERICO2005 ZERICO2005 deleted the cxx20_bit branch April 16, 2025 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants