C++ static_cast runtime overhead

前端 未结 1 1561
北海茫月
北海茫月 2020-12-03 10:53

See the code below.

a) Does, in this case (simple inheritance, no virtual members), the static cast in B::df() have any overhead (whatsoever)? I found some conflicti

相关标签:
1条回答
  • 2020-12-03 11:28

    static_cast<T>(e) is equivalent to creating an invented temporary variable v in the following way:

    T v(e); //where T is an arbitrary type  and e is an arbitrary expression.
    

    The runtime cost of a static_cast is exactly the cost of the above statement

    0 讨论(0)
提交回复
热议问题