On many compilers (tested on gcc 9.2) the std::accumulate function will use the type of the initial value as the accumulated value type. The previous version of the code passed a literal '1' which defaults to an 'int' type. This makes the code vulnerable to type overflows for arrays with many elements. Explicitly casting to size_t should fix this.
On many compilers (tested on gcc 9.2) the std::accumulate function will use the type of the initial value as the accumulated value type. The previous version of the code passed a literal '1' which defaults to an 'int' type. This makes the code vulnerable to type overflows for arrays with many elements. Explicitly casting to size_t should fix this.