reinterpret_cast cast cost

后端 未结 6 881
梦谈多话
梦谈多话 2020-12-29 18:36

My understanding is that C++ reinterpret_cast and C pointer cast is a just a compile-time functionality and that it has no performance cost at all.

Is this true?

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-29 19:03

    That's right. No cost other than any gain/loss in performance for performing instructions at the new width, which I might add, is only a concern in rare cases. Casting between pointers on every platform I've ever heard of has zero cost, and no performance change whatsoever.

提交回复
热议问题