| ▲ | debugnik 3 hours ago | |||||||
That's a conversion, not the same. The naive equivalent to transmute would be
But reinterpret_cast isn't valid in a constexpr scope. | ||||||||
| ▲ | poppadom1982 2 hours ago | parent | next [-] | |||||||
My point is, in your exact example both reinterpret_cast and C-style casts have the exact same behavior, making the example bad. If you want to showcase a deficiency of C++, it would make sense to pick something where the difference between cast types actually matters. | ||||||||
| ▲ | TuxSH an hour ago | parent | prev [-] | |||||||
> But reinterpret_cast isn't valid in a constexpr scope. std::bit_cast is | ||||||||
| ||||||||