A compact C++ small vector implementation using tagged pointers for stack-allocated storage with minimal overhead.
ankerl::svector is a C++ small vector container that stores elements directly on the stack for small sizes, avoiding heap allocations. It uses a tagged pointer design to achieve an extremely compact memory footprint—as low as 8 bytes—while providing the full API of std::vector. The project solves the problem of memory overhead in small vector implementations, offering a lightweight alternative to libraries like absl::InlinedVector and boost::small_vector.
C++ developers working on performance-sensitive applications, embedded systems, or memory-constrained environments who need efficient small vector containers with minimal overhead.
Developers choose ankerl::svector for its unparalleled memory efficiency—it has the smallest size and overhead among small vector implementations—while maintaining competitive performance. Its compatibility with std::vector's API makes it easy to integrate, and its stack allocation reduces heap usage for small collections.
Compact SVO optimized vector for C++17 or higher
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses only 8 bytes with 1 byte overhead, compared to 24+ bytes for alternatives like boost::small_vector, as shown in the README's size comparison table.
Benchmarks indicate it's only about 20% slower than std::vector in random insert and faster than absl::InlinedVector in some cases, making it viable for performance-sensitive code.
Implements the complete std::vector interface, ensuring drop-in replacement compatibility and ease of integration, as stated in the key features.
Stores up to 127 elements directly on the stack, eliminating heap allocations for small collections and reducing memory fragmentation, per the design description.
Can only store up to 127 elements on the stack; beyond that, it switches to heap allocation, which might not be suitable for larger datasets or dynamic workloads.
The README admits it's 'new and relatively untested' with a disclaimer, making it risky for production use compared to established libraries like std::vector.
Benchmarks show it's slower than std::vector in push_back and random access operations, which could impact high-throughput scenarios where speed is paramount.
Primarily uses Meson build system; CMake support is limited to convenience, which might complicate integration for teams standardized on CMake or other build tools.