annulen at yandex.ru
Thu May 16 23:56:41 CEST 2019
17.05.2019, 00:44, "Konstantin Shegunov" <kshegunov at gmail.com>:
> User story:
> The API is always going to rule supreme over any implementation detail or efficiency. The API is what you present to the user, not the implementation. The moment you start sacrificing good API, one that's fleshed out and convenient to the user, for a simpler implementation you end up where the STL is - so convoluted it's hardly worth making anything with it. Take the glorified std::vector - appending a vector to another takes 3 arguments, and removing an element from it, or accessing its value through an iterator for that matter, involves rather poorly hidden pointer arithmetic.
In C++ there is a convention that ugly things should look ugly in code. Removing element from the middle or beginning of contiguous container is ugly thing. If you need such operation in your code, you should consider using linked list instead, which allows to remove element with one method call (std::list::remove or std::list::remove_if)
More information about the Development