以下のコード スニペットは、ここの Herb Sutter のブログからのものです。
g++ 出力10
. MSVC も出力を行います10
。出力はコンパイラによって異なる場合があります。
変数i
がどのようにインクリメントされるか理解できません。出力がどのようになるのか、誰でも説明できますか10
?10
本当に正しい出力ですか?
#include <iostream>
#include <vector>
#include <string>
int main()
{
std::vector<int> v = { 0, 0 };
int i = 0;
v[i++] = i++;
std::cout << v[0] << v[1] << std::endl;
}