|
 |
Darren New wrote:
> Warp wrote:
>> std::for_each(someList, [&total](int x) { total += x });
>
> And, really, what's the advantage of this over a normal for loop?
You tell me.
int total = 0;
std::vector<int> someList;
std::for_each(someList, [&total](int x) {
total += x;
});
vs
int total = 0;
std::vector<int> someList;
for (std::vector<int>::const_iterator i = someList.begin(); i !=
someList.end(); ++i) {
total += *i;
}
Post a reply to this message
|
 |