News for hackers. Stuff that matters.
Re:Clever code is probably the worst code you could write by leetcrew on Tuesday May 21, 2024 @10:41PM (#40436829)
the readability issue here is in part that function arguments are purely positional in c++.

a little over the top for this simple example, but you can always create local variables to document intention.

  auto initVal = 0;
  auto accumulateOp = [](int a, b) {return a + b;};
  return std::accumulate(x.begin(), x.end(), initVal, accumulateOp);
I'd prefer to see a for each loop over algorithms functions in such simple cases, but I'd prefer almost anything over direct indexing when it isn't necessary. when I see that in new code, my first thought is always "what am I missing here?".

There are no comments on this comment yet.