[#prevector-01] = xref:prevector-0c.adoc[prevector]<36, unsigned char> :mrdocs: Implements a drop‐in replacement for std::vector<T> which stores up to N elements directly (without heap allocation). The types Size and Diff are used to store element counts, and can be any unsigned + signed type. == Synopsis Declared in `<prevector.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<> class xref:prevector-0c.adoc[prevector]<36, unsigned char>; ---- == Description Storage layout is either: * Direct allocation: * Size _size: the number of used elements (between 0 and N) * T direct[N]: an array of N elements of type T (only the first _size are initialized). * Indirect allocation: * Size _size: the number of used elements plus N + 1 * Size capacity: the number of allocated elements * T* indirect: a pointer to an array of capacity elements of type T (only the first _size are initialized). The data type T must be movable by memmove/realloc(). Once we switch to C++, move constructors can be used instead. == Types [cols="1,4"] |=== | Name| Description | xref:prevector-01/const_iterator.adoc[`const_iterator`] | Read‐only contiguous iterator over the container's elements. | xref:prevector-01/iterator.adoc[`iterator`] | Mutable contiguous iterator over the container's elements. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:prevector-01/const_pointer.adoc[`const_pointer`] | Pointer to a const element. | xref:prevector-01/const_reference.adoc[`const_reference`] | Reference to a const element. | xref:prevector-01/difference_type.adoc[`difference_type`] | Signed type used to represent distances between iterators. | xref:prevector-01/pointer.adoc[`pointer`] | Pointer to an element. | xref:prevector-01/reference.adoc[`reference`] | Reference to an element. | xref:prevector-01/size_type.adoc[`size_type`] | Unsigned type used to store element counts. | xref:prevector-01/value_type.adoc[`value_type`] | Type of the elements held by the container. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:prevector-01/2constructor-0d.adoc[`prevector`] [.small]#[constructor]# | Constructors | xref:prevector-01/2destructor.adoc[`~prevector`] [.small]#[destructor]# | Destroys the container, freeing any heap allocation. | xref:prevector-01/operator_assign-08.adoc[`operator=`] | Assignment operators | xref:prevector-01/allocated_memory.adoc[`allocated_memory`] | Returns the number of bytes held in the heap allocation, or zero when stored inline. | xref:prevector-01/assign-03.adoc[`assign`] | `assign` overloads | xref:prevector-01/back-0b.adoc[`back`] | `back` overloads | xref:prevector-01/begin-0e.adoc[`begin`] | `begin` overloads | xref:prevector-01/capacity.adoc[`capacity`] | Returns the number of elements the container can hold without reallocating. | xref:prevector-01/clear.adoc[`clear`] | Removes all elements, leaving the container empty. | xref:prevector-01/data-092.adoc[`data`] | `data` overloads | xref:prevector-01/emplace_back.adoc[`emplace_back`] | Constructs a new element in place at the end of the container. | xref:prevector-01/empty.adoc[`empty`] | Returns whether the container holds no elements. | xref:prevector-01/end-01.adoc[`end`] | `end` overloads | xref:prevector-01/erase-0a.adoc[`erase`] | `erase` overloads | xref:prevector-01/front-0d.adoc[`front`] | `front` overloads | xref:prevector-01/insert-07.adoc[`insert`] | `insert` overloads | xref:prevector-01/operator_subs-04.adoc[`operator[]`] | Subscript operators | xref:prevector-01/pop_back.adoc[`pop_back`] | Removes the last element. | xref:prevector-01/push_back.adoc[`push_back`] | Appends a copy of `value` to the end of the container. | xref:prevector-01/reserve.adoc[`reserve`] | Ensures capacity for at least `new_capacity` elements without changing the size. | xref:prevector-01/resize.adoc[`resize`] | Resizes the container to hold `new_size` elements, value‐initializing any new ones. | xref:prevector-01/resize_uninitialized.adoc[`resize_uninitialized`] | Changes the size to `new_size` without initializing any newly added elements. | xref:prevector-01/shrink_to_fit.adoc[`shrink_to_fit`] | Reduces the capacity to match the current size. | xref:prevector-01/size.adoc[`size`] | Returns the number of elements currently stored. | xref:prevector-01/swap.adoc[`swap`] | Exchanges the contents of this container with `other`. | xref:prevector-01/operator_eq.adoc[`operator==`] | Returns whether this container holds the same elements as `other`. | xref:prevector-01/operator_lt.adoc[`operator<`] | Orders two containers lexicographically by their elements. |=== == Static Data Members [cols="1,4"] |=== | Name| Description | xref:prevector-01/STATIC_SIZE.adoc[`STATIC_SIZE`] | Number of elements stored inline before switching to heap allocation. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#