C++ When should we prefer to use a two chained static_cast over reinterpret_cast

前端 未结 6 1530
不思量自难忘°
不思量自难忘° 2020-12-04 01:29

First of all, this is not a duplicate of Why do we have reinterpret_cast in C++ when two chained static_cast can do it\'s job?.

I know situations where we cannot use

6条回答
  •  既然无缘
    2020-12-04 02:26

    Always use reinterpret cast as a last resort - it doesn't do any checking! - so if you can chain two, three or ten statements together that do some kind of validation on the operation then you've gained something worthwhile.

提交回复
热议问题