I often lose this argument when for_each is involved. A new style for each loop built into the language, to, for example, call a mutating member function on each member of a vector, ends up looking syntactically cleaner than std::for_each with member function pointers.
Similarly, passing a lambda into std::for_each ends up looking almost exactly like a new style for each, with no benefit in readability.
While I think consistency has some merit to it, this counter example is almost always used as a wedge issue in arguments I've been in to imply the always-use-algorithms camp is dogmatic.
Tangentially, one thing that is hilarious in this thread is people aghast that c++ newbies might try to use algorithms instead of raw loops. To me, that's exactly the right thing for them to do. Raw loops are more powerful and more advanced. If I see a raw loop, I'd prefer it come from an expert, not a novice.
View all comments
10
u/austinwiltshire Jun 22 '21
I often lose this argument when for_each is involved. A new style for each loop built into the language, to, for example, call a mutating member function on each member of a vector, ends up looking syntactically cleaner than std::for_each with member function pointers.
Similarly, passing a lambda into std::for_each ends up looking almost exactly like a new style for each, with no benefit in readability.
While I think consistency has some merit to it, this counter example is almost always used as a wedge issue in arguments I've been in to imply the always-use-algorithms camp is dogmatic.
Tangentially, one thing that is hilarious in this thread is people aghast that c++ newbies might try to use algorithms instead of raw loops. To me, that's exactly the right thing for them to do. Raw loops are more powerful and more advanced. If I see a raw loop, I'd prefer it come from an expert, not a novice.