Better memory management
So, this humble writer claims our nice but simple Vector<T> type is no match for std::vector<T>. That may seem like a bold claim: after all, we seemed to do what was needed and, no less, we used algorithms instead of raw loops; we caught exceptions as we wanted to be exception-safe but limited ourselves to cleaning up the resources… What are we doing wrong?
If you run comparative benchmarks between a Vector<int> object and a std::vector<int> object, in fact, you will probably not notice much of a difference in the respective numbers of both tests. For example, try adding a million int objects (through push_back()) to each of these containers and you will think our container holds its own quite well. Cool! Now, change that to a comparative test between Vector<std::string> and std::vector<std::string> and you might be saddened a bit, seeing that we’re “left behind in the dust,” as they say.