The fastest way to do this is to not do it. Create Here's an outline of a new collection class that will iterate overlooks like a rangeread-only array of consecutive integers, without storing a copy of each one.
class range {
private:
int low, high;
public:
range_iteratortypedef int iterator;
range(int low, int high) { this.low = low; this.high = high; }
iterator begin(); { return low; }
range_iteratoriterator end() { return high + 1; }
int operator[](int index) { return low + index; }
}
...
range r(1, 1000);
for (r::iterator i = r.begin(); i != r.end(); ++i) { ... }
If you need a writable collection, then the answer depends on how you want to modify it after creation.