A Summation Function For Boost.MultiArray in C++
Implement a recursive std::reduce()
You shouldn't need to special-case boost::multi_array and related types, as those types already act like STL containers (they provide begin() and end() for example). The main problem however is how to deduce the return type of recursive_sum(). Your functions seem to work because they deduce T from a boost::multi_array&lt;T, Dims&gt;, but do they really? Your recursive_sum() recurses over the dimensions of a multi_array, but it doesn't actually handle nested multi_arrays, like for example:
boost::multi_array&lt;boost::multi_array&lt;double, 2&gt;, 3&gt; array;

The reason is that in the above case, calling recursive_sum(array) will deduce T to be a boost::multi_array&lt;double, 2&gt; instead of a double.
To solve this issue, I would do what std::reduce() does, and sidestep the issue by requiring an initial value for the sum. The type of this initial value will also be the return type. For example:
template&lt;class T, class ValueType, class Function = std::plus&lt;ValueType&gt;&gt;
auto recursive_reduce(const T&amp; input, ValueType init, const Function&amp; f)
{
    return f(init, input);
}

template&lt;class Container, class ValueType, class Function = std::plus&lt;ValueType&gt;&gt;
requires is_iterable&lt;Container&gt;
auto recursive_reduce(const Container&amp; input, ValueType init, const Function&amp; f = std::plus&lt;ValueType&gt;())
{
    for (const auto &amp;element: input) {
        auto result = recursive_reduce(element, ValueType{}, f);
        init = f(init, result);
    }

    return init;
}

Then you can call it like so:
boost::multi_array&lt;...&gt; array(...);
std::cout &lt;&lt; recursive_reduce(array, 0.0) &lt;&lt; &quot;\n&quot;;

You could perhaps write some template to find the inner-most value type, so that you can use that as a default for the template parameter ValueType in recursive_reduce(), and then you can use {} as the default value for init, and be able to write:
std::cout &lt;&lt; recursive_reduce(array) &lt;&lt; &quot;\n&quot;;