是否有人知道为什么升压拉姆达的for_each /变换益智
vector<int> test(10);
int a=0;
for_each(test.begin(),test.end(),(_1+=var(a),++var(a)));
for_each(test.begin(),test.end(),(cout << _1 << " "));
cout << "\n"
给出: “0 1 2 3 4 5 6 7 8 9”
但
transform(test.begin(),test.end(),test.begin(), (_1+=var(a),++var(a)));
...(as before)
给出:“1 2 3 4 5 6 7 8 9 10“
?
花了我几个重读,以获得它,但谢谢:-) – 2008-11-25 12:02:46