In my program, I often need an owning array-like container - i.e. for data stored contiguously in memory, but vector is too flexible and less practical or efficient than it could be.
The requirements differ from std::vector
in one or more aspects such as:
- Elements can only be inserted at the end, without moving other elements
- Capacity cannot be changed after construction / after compilation
- Size can't be changed after construction / after compilation
- Storage is inherent in the class and does not involve an allocator
- No weird special-casing for a single type like
std::vector<bool>
- References and/or iterators don't get invalidated on insertion
- etc.
If necessary, I'll implement such a container myself, but likely it already exists in the standard library or in a popular one like Boost.
The thing is, it can be hard to find, maybe it has a fancy name that you don't expect. So, what vector-like containers within the above parameter space exist?
Even if my requirements aren't met in an existing container, a reference list helps: if I do end up implementing a new container, I can adopt appropriate names and avoid confusing names.