Implementing range from_to with step
I think the easiest way to solve this is to first calculate how many steps it takes to go from from to to, and then just build an array of that many elements. That also has the advantage that you can reserve the right amount of elements in the vector up front. You also have to make sure that step has the correct sign.
if (from &lt;= to != step &gt; 0)
    step = -step;

size_t distance = std::abs(to - from);
size_t stepsize = std::abs(step);
size_t nsteps = (distance + stepsize - 1) / stepsize;

std::vector&lt;int&gt; range;
range.reserve(nsteps);

for (size_t i = 0; i &lt; nsteps; ++i)
    range.push_back(from + i * step);

You also might want to add some check that step is not zero.