2 ms·
> But if you do that, it's not safe! static_cast does narrowing foor the case mentioned. reinterpret_cast would just reinterpret the same bit pattern as anothe
by germandiago 4y ago
> But if you do that, it's not safe!
static_cast does narrowing foor the case mentioned. reinterpret_cast would just reinterpret the same bit pattern as another type.
Whether it is equivalent or not is another story. For example, casting a float to an int will narrow but also will convert the internal format.
You can catch some overflow by {} initialization.