[Solved] What variations of vector-like containers already widely established? Do I have to write my own? [closed]

[ad_1]

Here are the ones I know of:

There are also “variable-length arrays” and “arrays with runtime bounds”, which do not exist in C++; the former exists in C. See also this question and this answer about these non-C++ containers.

Let’s compare the features of all of these. If the container you want doesn’t match one of the lines below exactly, you’ll need to implement your own and choose a name for it.

CriterionC arrayarrayvectorunique_ptrvalarraydynarraystatic_vectorsmall_vectorstable_vector
Origin/librarylanguagestdstdstdstddiscarded stdBoostBoostBoost
Type parametersT,NT,NT,ATTTT,C,OT,N,A,OT,A
Capacity fix timeCompileCompileNever(Construct)NeverConstructCompileNeverNever
Size fix timeCompileCompileNeverN/ANeverNeverConstructNeverNever
Size = capacity always?N/A
Storage typically onStackStackHeapHeapHeapHeapStackStack/HeapHeap
Stable iterators?N/AN/AN/AN/AN/A(✔)
Constraint on element type

Template parameter legend:

  • A for allocator
  • T for element type
  • N for size in number of elements
  • C for capacity in number of elements
  • O for options

Finally, an interesting but less popular vector-like container is the “veque”, or deque-vector amalgam.

4

[ad_2]

solved What variations of vector-like containers already widely established? Do I have to write my own? [closed]