diff -r 3fb8ad4d27b1 -r 3eace926af7f src/generics/functions.h --- a/src/generics/functions.h Sat May 26 17:28:15 2018 +0300 +++ b/src/generics/functions.h Wed May 30 22:31:06 2018 +0300 @@ -224,6 +224,24 @@ return static_cast(round(value / interval) * interval); } +/* + * Returns the empty sum. (recursion base) + */ +template +T sum() +{ + return {}; +} + +/* + * Returns the sum of n arguments. + */ +template +T sum(const T& arg, Rest&&... rest) +{ + return arg + sum(rest...); +} + // Copy of qOverload so as to drop Qt version requirement from 5.7 to 5.5. #if (QT_VERSION < QT_VERSION_CHECK(5, 7, 0)) template