New Sequence Points in C++11

前端 未结 2 2004
死守一世寂寞
死守一世寂寞 2020-12-30 15:19

With the new college year upon us.
We have started to receive the standard why does ++ i ++ not work as expected questions.

After just answering one

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-30 15:46

    I don't think sequencing is relevant to your situation. The expression ++i++ is grouped as ++(i++), so:

    • If i is a built-in type, then this is invalid, since i++ is an rvalue.

    • If i is of user-defined type and the operators are overloaded, this is a nested function call, such as T::operator++(T::operator++(i), 0), and function arguments are evaluated before the function call is evaluated.

提交回复
热议问题