It rather depends on what you want to do with those numbers.
If you really want a range, not a container, then boost::irange
will more than suffice. It doesn't even need any [substantial] memory!
It lets you do cool stuff like this:
#include <iostream>
#include <boost/range/irange.hpp>
using boost::irange;
using std::cout;
int main()
{
for (auto i : irange(0, 42))
cout << i << ' ';
}
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41