|
ZenitUI
Retained-mode C++20 UI framework
|
A vector whose first N elements live inside the object.
More...
#include <SmallVector.hpp>
Public Member Functions | |
| SmallVector (std::initializer_list< T > init) | |
| Construct from an initializer list. | |
| SmallVector (const SmallVector &)=default | |
| SmallVector & | operator= (const SmallVector &)=default |
| SmallVector (SmallVector &&o) noexcept | |
| SmallVector & | operator= (SmallVector &&o) noexcept |
| SmallVector & | operator= (std::initializer_list< T > init) |
| Replace contents with the given initializer list. | |
| std::size_t | size () const |
| Number of elements currently stored. | |
| bool | empty () const |
| true when there are no elements. | |
| void | clear () |
| Remove all elements. | |
| void | reserve (std::size_t n) |
Reserve storage for at least n elements. | |
| void | push_back (const T &value) |
Append a copy of value. | |
| void | push_back (T &&value) |
Append a moved value. | |
| T & | operator[] (std::size_t i) |
| const T & | operator[] (std::size_t i) const |
| T * | begin () |
| T * | end () |
| const T * | begin () const |
| const T * | end () const |
| bool | operator== (const SmallVector &o) const |
| bool | operator!= (const SmallVector &o) const |
A vector whose first N elements live inside the object.
| T | Element type. Must be default-constructible for the inline array. |
| N | Number of elements stored inline before a heap allocation is made. |
Behaves like std::vector<T> but avoids a heap allocation for small payloads (typically 2–8 elements). When size() exceeds N, the inline contents are moved into an internal std::vector and all further growth uses that heap buffer.
The inline_ array is always present, so the object size is at least N * sizeof(T). Choose N accordingly.
|
inline |
Remove all elements.
Does not free the heap buffer if one exists.
|
inline |
Append a copy of value.
Triggers inline → heap promotion on overflow.
|
inline |
Reserve storage for at least n elements.
Values n <= N are no-ops: inline storage is already sufficient.