Allowing different fundamental types to share the same memory location by using std::bit_cast instead of std::variant or union?
It’s possible to store ints or floats in the same memory location using std::bit_cast (including ints larger than 2^24 i.e. they can’t be stored as whole numbers in floats because the mantissa has too few bits). Example:
Allowing different fundamental types to share the same memory location by using std::bit_cast instead of std::variant or union?
It’s possible to store ints or floats in the same memory location using std::bit_cast (including ints larger than 2^24 i.e. they can’t be stored as whole numbers in floats because the mantissa has too few bits). Example: