An open API service indexing awesome lists of open source software.

https://github.com/p-ranav/small_vector

"Small Vector" optimization for Modern C++: store up to a small number of items on the stack
https://github.com/p-ranav/small_vector

array buffer container cpp11 header-only heap memory-management modern-cpp optimization single-header single-header-lib small small-buffer-optimization stack vector

Last synced: 3 months ago
JSON representation

"Small Vector" optimization for Modern C++: store up to a small number of items on the stack

Awesome Lists containing this project

README

          

small_vector
============

"Small Vector" optimization for Modern C++: store up to a small number of items on the stack

## Example

```cpp
#include
#include

#include
using namespace sv;

int main() {

// This small vector can hold up to 4 items on the stack
small_vector vec{1, 2, 3, 4};

// It will move its contents to the heap if it
// contains more than four items:
vec.push_back(5);

// Access and modify contents
vec[0] = vec[1] + vec[2];

// Iterate and print contents
std::copy(vec.begin(), vec.end(), std::ostream_iterator(std::cout, " "));

}
```