std::bit_cast
is apparently being introduced in c++20. and std::start_lifetime_as
is proposed for c++23 (from P0593R5). As they appear to both require that the datatypes involved be trivial anyways, will there be any need for the former once the latter is introduced?
Apologies in advance for not providing any more information about these new features. I only just heard about them after watching a cppcon 2019 lecture on type-punning, and I wasn't able to find much about start_lifetime_as
with google. I'm hoping someone else who sees this might know more.
The answer is trivial: bit_cast
returns a value, whereas start_lifetime_as
“alters” memory (in a way that exists in the abstract machine but is not expected to affect any physical bits). You use the former to (once) interpret an existing object as a set of bits; you use the latter to (permanently) interpret existing bits as an object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With