A Summation Function For Arbitrary Nested Vector Implementation In C++ I am trying to deal with some calculations on nested vector data in C++. The nested vector data may be like std::vector&lt;long double&gt;, std::vector&lt;std::vector&lt;long double&gt;&gt;, or std::vector&lt;std::vector&lt;std::vector&lt;long double&gt;&gt;&gt;. I want to focus on summation here, and the calculation of summation could be done with the Sum function implemented here. Is there any possible improvement of this code?
The function declaration part is as below.
template &lt;class T&gt;
static long double Sum(const std::vector&lt;T&gt; inputArray);
static long double Sum(long double inputNumber);

The function implementation part is as below.
template&lt;class T&gt;
inline long double Sum(const std::vector&lt;T&gt; inputArray)
{
    long double sumResult = 0.0;
    for (auto&amp; element : inputArray)
    {
        sumResult += Sum(element);
    }
    return sumResult;
}

inline long double Sum(long double inputNumber)
{
    return inputNumber;
}

Test for this sum function:
std::vector&lt;long double&gt; testVector1;
testVector1.push_back(1);
testVector1.push_back(1);
testVector1.push_back(1);
std::cout &lt;&lt; std::to_string(Sum(testVector1)) + &quot;\n&quot;;

std::vector&lt;std::vector&lt;long double&gt;&gt; testVector2;
testVector2.push_back(testVector1);
testVector2.push_back(testVector1);
testVector2.push_back(testVector1);
std::cout &lt;&lt; std::to_string(Sum(testVector2)) + &quot;\n&quot;;

std::vector&lt;std::vector&lt;std::vector&lt;long double&gt;&gt;&gt; testVector3;
testVector3.push_back(testVector2);
testVector3.push_back(testVector2);
testVector3.push_back(testVector2);
std::cout &lt;&lt; std::to_string(Sum(testVector3)) + &quot;\n&quot;;

Oct 18, 2020 Update
Reference:

The follow-up question:
A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++

The further implementation with c++-concepts:
https://stackoverflow.com/q/64414869/6667035
The template seems reasonable, although inputArray is a misnomer. However, there is a major drawback that can be remedied with a single &amp;: use call-by-reference instead of call-by-value (see guidelines):
template&lt;class T&gt;
inline long double Sum(const std::vector&lt;T&gt; &amp;inputArray)
{ 
    ...
}

Other than that it's perfectly fine for summing arbitrary nested std::vector&lt;double&gt;.
That being said, there is some room for further experiments:

enable Sum for anything that has begin() and end()
enable Sum for other types than double (e.g. int)

Also, I'm a little bit concerned by the comment that declaration and definition were split. While it's possible, it's usually not intended.