It can reduce more than just strings
Your code is now very generic. In fact, there is nothing in the code referring to strings of any kind. For example, you can sum a vector of integers with it:
std::vector<int> int_vector = {1, 2, 3, 4, 5};
std::cout << recursive_reduce_string<0>(int_vector) << '\n';
So you basically reimplemented your own recursive_reduce()
with unwrap level, except instead of saying how many levels to unwrap, now the template parameter says how many levels to leave wrapped.
You should either rename this new function such that it doesn't mention strings anymore, and makes it clear that the parameter is how many levels to leave unwrapped, or alternatively, consider merging this into recursive_reduce()
, and maybe use negative values of the template parameter to get the new behavior?