5 ms·
A more declarative programming style has many potential benefits. The trouble is, the version in that style is supposed to look something like this: total
by Chris_Newton 16y ago
A more declarative programming style has many potential benefits. The trouble is, the version in that style is supposed to look something like this:
total dice = sum (map faceValue dice)
C++ is showing its age now, as ideas from other programming styles are entering the mainstream. Modern programming languages, designed with the benefit of hindsight, support those idioms natively and much more effectively than a bolted-on library, the cleverness of the Boost implementers notwithstanding.
In this context, I think one of the commenters on the original article probably had it right: given that C++ is essentially an imperative language, using the new range-based for loops is a more natural way to write this algorithm.