Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: