Hi, i create smart pointers class. When i start to test it, i was upset. Because when i calculate the time to execution of func1, it was 5 times slower than func2.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void func1()
{
SmartPtr<int> p(300000000); //creates array of 300000000 ints
for(int i = 0; i < 300000000; i++)
p[i] = i; //here is called operator[]
}
void func2()
{
int * k = newint[300000000];
for(int i = 0; i < 300000000; i++)
k[i] = i;
delete[] k;
}
interesting thing is that, when i delete p[i] = i; this part of code func1 and func2 time is equal.
So i think, there is some problem in operator[]
here is it's code
Explain to me what inline means then, akmal, because i seem to have missed the point, i never knew that if a function is in the body of a class it becomes an inline function.
And, what was the solution?
Skillless, excuse me).
I was testing in debug mode, when i start testing in release mode it was good, because time of my smart pointers and c++ pointers is equal).
I think in debug mode there is a lot of debug info, am i right?
I'm using VS2008 compiler.