Commit 02b8d498 by Quentin Khan

### Refactor variadic sums to remove recursion

parent 639ed29f
 ... ... @@ -265,16 +265,12 @@ private: } /** Variadic sum recursion end */ template A sum(const A& a) { return a; } /** Variadic sum */ template A sum(const A& a, const B& b, const Args&... args) { return sum(a+b, args...); template auto sum(const Args&... args) -> typename std::common_type::type { typename std::common_type::type res = {}; auto l = {(res += args, 0) ...}; (void)l; return res; } ... ...
 ... ... @@ -564,36 +564,19 @@ private: } /** \brief Variadic sum recursion end * * \tparam T Return type * * \param a Sum last sub-sum * * \return The parameter a */ template T sum(const T& a) { return a; } /** \brief Variadic sum * * This sum is implemented in a recursive manner * * \tparam T First operand type * \tparam U Second operand type * \tparam Ts Other operands types * \tparam Ts Operands types * * \param a First operand * \param b Second operand * \param bs Other operands * \param ts Operands * * \return The sum a + b + bs... * \return The sum of ts... */ template T sum(const T& a, const U& b, const Ts&... bs) { return sum(a+b, bs...); template auto sum(const Ts&... ts) -> typename std::common_type::type { typename std::common_type::type res = {}; auto l = {(res += ts, 0)...}; (void)l; return res; } ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!