I know how to fill an std::vector with non-trivial initial values, e.g. sequence numbers:
void IndexArray( unsigned int length, std::vector&a
If you're using SGI STL (or a derivative, such as STLPort), you can use iota. :-)
void IndexArray(unsigned int length, vector& v) { vector(length).swap(v); iota(v.begin(), v.end(), 0); }