I did the test on a release build. My main objective is to have an array with a member _size. It is easy to implement but if std::vector is as fast as a simple array class, I'll use it.Quote:
Originally Posted by Paul McKenzie
I've also compared how fast it was to assign values to an array and to copy it to another array:
is still more than 20% faster thanCode:int* a=new int[size];
int* b=new int[size];
for(int i=0; i<size;i++) a[i]=i;
memcpy(b,a,size*sizeof(a));
push_back is quite slow, but I can't do:Code:std::vector<int> x;
std::vector<int> y;
x.reserve(size);
y.reserve(size);
for(int i=0; i<size;i++) x.push_back(i);
y.assign(x.begin(), x.end());
because the iterators returned by x.begin() and x.end() are not incremented, and I can't use assign or copy....Code:for(int i=0; i<size;i++) x.[i]=i;
Do you see any way to make that faster using vector?
Thanks again to everybody for your help
Ujl
