Probably some typos are not everything, but I would smooth the whole range.
This is based on the idea that a range can be described as
x_0 + d_0*(x_1+d_1*(x_2+d_2....)
So we can collapse this way
std::vector<int> lower_bound{-4,-5,6}; std::vector<int> upper_bound{6,7,4};
Edit: be more general:
template <typename D> void multi_for(const std::vector<int>& lower_bound, const std::vector<int> upper_bound, D d) { std::vector<int> ranges; for (size_t i = 0; i < lower_bound.size(); i++) { ranges.push_back(upper_bound[i]-lower_bound[i]); } size_t numel = std::accumulate(ranges.begin(), ranges.end(), std::multiplies<int,int>{}); for (int idx = 0; idx < numel; idx++) {
Ideahat
source share