Is there a performance difference between i++ and ++i in C++?

前端 未结 17 2034
臣服心动
臣服心动 2020-11-21 17:15

We have the question is there a performance difference between i++ and ++i in C?

What\'s the answer for C++?

17条回答
  •  余生分开走
    2020-11-21 18:10

    @wilhelmtell

    The compiler can elide the temporary. Verbatim from the other thread:

    The C++ compiler is allowed to eliminate stack based temporaries even if doing so changes program behavior. MSDN link for VC 8:

    http://msdn.microsoft.com/en-us/library/ms364057(VS.80).aspx

提交回复
热议问题