| An implementation of std::vector can use exceptions so it is slower, potentially. |
new[] also uses exceptions, in the sense that an exception will be raised when allocation fails. vector's operator[] makes unsafe access (no checks are made, no exceptions are raised) just as "standard" operator []. I don't see any differences here.
| This means C-style arrays are useless as well, so it should just be removed yes ? |
They are different, as they are allocated on the stack (when local), and they provide initialization lists. So their existence is justified.
| Abramus, can you get us started by implementing std::vector<T> without using new []? Remember, it has to be contiguous. |
Well, sure. All you need is malloc and placement new (without []). realloc would also help. Not only this is possible, this is actually how things are done. Even if new[] is used, it only allocates a raw array of bytes, i.e. malloc or any other C-like allocation function could be easily used instead. Otherwise vector would be terribly inefficient.
Look guys, maybe I was a little too offensive with my statement. We all know why new[] exists - at first there was no vector, and later nobody wanted to break backward compatibility. But from today perspective, new[] seems to be redundant. We could discuss if backward compability, or lack of built-in dynamic array type, is a good thing. But this would be probably too off-topic.