Narek Narek - 1 year ago 113
C++ Question

std::vector::insert vs std::list::operator[]

I know that

is not implemented as it has bad performance. But what about
it is as much inefficient as much
is. What is the explanation behind?

Answer Source

std::vector::insert is implemented because std::vector has to meet requirements of SequenceContainer concept, while operator[] is not required by any concepts (that I know of), possible that will be added in ContiguousContainer concept in c++17. So operator[] added to containers that can be used like arrays, while insert is required by interface specification, so containers that meet certain concept can be used in generic algorithms.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download