I have a question, which very likely has been asked like this before, because I think what I want is something that a considerable amount of people would want. However I could n
The Boost.Range way to solve this problem is to use the transform
iterator adaptor:
auto rng = boost::irange(1, 10)
| boost::adaptors::transformed([](int i) { return i * i; });
std::vector v{rng.begin(), rng.end()};
Note how this separates the concerns of the transformation from the start/stop/step (optional) parameters of the input range.