Is reinterpret_cast mostly useless?

后端 未结 5 505
佛祖请我去吃肉
佛祖请我去吃肉 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 04:10

    The standard specifies what has to happen on all platforms, you don't have to do that. If you limit your portability requirements to platforms where your reinterpret_cast actually works, that's fine.

    On platforms that actually support a uint16_t, the cast is likely to work. On platforms where char16_t is 18, 24, 32, or 36 bits wide, it might not do the right thing. The question is, do you have to support such platforms? The language standard wants to.

提交回复
热议问题