reinterpret_cast cast cost

后端 未结 6 903
梦谈多话
梦谈多话 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 18:57

    You're right, but think about it: reinterpret_cast means maybe a bad design or that you're doing something very low level.

    dynamic-cast instead it will cost you something, because it has to look in a lookup table at runtime.

提交回复
热议问题