Quickstart
Integration:
1 |
|
1 2 3 4 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
1 2 3 4 5 6 7 8 9 |
|
Note
Get the binary package from the release section.
These binaries refer to the latest release version of small.
Hint
If you need a more recent version of small
, you can download the binary packages from the CI artifacts or build the library from the source files.
Note
Ensure your C++ compiler and CMake are up-to-date and then:
1 2 3 4 5 6 7 8 9 10 11 |
|
1 2 3 4 5 6 7 8 9 10 11 |
|
1 2 3 4 5 6 7 8 9 10 11 |
|
Parallel Build
Replace --parallel 2
with --parallel <number of cores in your machine>
Setting C++ Compiler
If your C++ compiler that supports C++17 is not your default compiler, make sure you provide CMake with the compiler location with the DCMAKE_C_COMPILER and DCMAKE_CXX_COMPILER options. For instance:
1 |
|
Note
Because containers are header-only, you can directly copy the contents from the source
directory into your project.
Hint
In that case, you are responsible for setting the appropriate target include directories and any compile definitions you might require.
Once the library is properly integrated, you can create containers from the namespace small
like any other STL container:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
All containers are optimized for the case when they're small but also efficient when they are large. The containers mix the common techniques found in other small container libraries:
- Inline allocation for small containers
- Custom expected sizes
- Identification of relocatable types
- Custom growth factors with better defaults
- Communication with system memory allocators
- Explicit consideration of CPU cache sizes and branch prediction
Most applications have many small lists and sets of elements. These containers avoid spending a lot of time with large containers that contain just a few elements. Small containers usually try to use the stack before dynamically allocating memory and try to represent associative containers with stack arrays, unless these sets are very large.
The following containers are available:
small::vector
small::max_size_vector
small::string
small::set
small::max_size_set
small::multiset
small::max_size_multiset
small::unordered_set
small::max_size_unordered_set
small::unordered_multiset
small::max_size_unordered_multiset
small::map
small::max_size_map
small::multimap
small::max_size_multimap
small::unordered_map
small::max_size_unordered_map
small::unordered_multimap
small::max_size_unordered_multimap
small::stack
small::queue
small::priority_queue
Although many compilers support small string optimization (SSO) already, this library will ensure all strings support SOO, custom inline sizes, relocation, and unicode.