Is reinterpret_cast mostly useless?

后端 未结 5 474
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 03:26

I\'ve read various previous questions about the use of reinterpret_cast, and I\'ve also read the relevant wording in the C++ standard. Essentially, what it comes down to is

5条回答
  •  隐瞒了意图╮
    2020-12-31 03:46

    There are some guarantees elsewhere in the standard (see the section on type representation which, IIRC, mandates that corresponding unsigned and signed types share the representation for the common values, still IIRC, there is also some text guaranteeing that you can read anything as characters). But note also that there are some places which lessen even the section you are reading (which states that things are implementation defined and unspecified): some forms of type punning are undefined behavior.

提交回复
热议问题