Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

You have 10 seconds to implement std::vector in plain C

Name: Anonymous 2016-07-20 3:56

Must support:

* Adding elements
* Regrowing

Name: Cudder !cXCudderUE 2017-01-07 15:48

>>64
More proof that C++ is based around dogmatic cargo-cult bullshit. At least std::vector has reserve(), but actually seeing that used correctly --- or at all --- is rare.

std::vector's real use-case is for huge arrays of unknown length, that you would otherwise have to implement with malloc() and realloc() anyway. Large fixed allocations go in static arrays, small static allocations go on the stack, and small dynamic allocations can either be treated as small static ones (if the upper limit is not too high) or a fixed heap allocation. They all have different characteristics and assuming std::vector is the best for all of those use-cases is just plain stupid.

Small inefficiencies add up.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List