A C++ template library for embedded applications
Designed and maintained by
Aster Consulting Ltd

Containers

The library defines a set of containers that have been specially tailored for embedded systems.
They have a maximum capacity fixed at compile time and make no calls to malloc/free or  new/delete.
They are completely deterministic.

Most container types have been designed to mimic, as far as possible, those found in the STL. Some do not have direct
STL equivalents.

As the storage for all of the container types is allocated as a contiguous block, they are extremely cache friendly.

Note: In the ETL vector<bool> really is a container and actually does contains bool.

Defined containers

array
bitset
bloom_filter
deque
flat_map & flat_multimap
flat_set & flat_multiset
forward_list
intrusive_forward_list
intrusive_stack
intrusive_queue
list
intrusive_list
map & multimap
unordered_map & unordered_multimap
optional
pool
priority_queue
queue
set & multiset
unordered_set & unordered_multiset
stack
string, wstring, u16string, u32string
variant
vector

To eliminate code bloat, most container templates utilise 'hoisting' where functionality, independent of the size and/or
type, is separated out in to base classes.

For example, vector<int, 5> and vector<int, 10> will share code from ivector<int>.
vector<int, 5>, vector<float, 7> and vector<int, 10> will all share code from vector_base.

The 'i' prefixed container types may be used as size independent pointer or reference types for all sizes of the derived
type.

etl::vector<int, 5>  vector1;
etl::vector<int, 10> vector2;

etl::ivector<int>* pvector;

pvector = &vector1;
pvector->push_back(3);

pvector = &vector2;
pvector->push_back(4);

Differences from the STL containers

As the containers have a fixed capacity, most also implement full() and available() member functions.

Any member functions that require rvalue references are not supported.

For maximal efficiency, the method of passing values is dependent on the type. Fundamental types and pointers are
passed by value; other types by const reference. The method for a particular instance is automatically selected at
compile time.

The method for implementing this can be found here.

Most of the containers allocate their storage from an internal instance of etl::pool.
Because of this the containers have a certain set of attributes that differ from the standard library.

• The storage for all containers is contiguous, thereby enhancing cache hits.
• No heap memory is used; no OS supplied memory management is required.
• Non-static containers declared locally within functions will store their contents on the stack.
• Copying or swapping a container is not a low cost action, as all of the contents will be copied.

Notes

Although the containers utilise inheritance, like the STL containers they are not intended to be used polymorphically.
ETL containers are not virtual.

Todo

Add other non-STL containers:-
Skip list.
Splay tree (etl::splay_map, etl::splay_set etc).
More intrusive containers.

Cache containers (Least Recently Used, Most Recently Used, Random Release)

Add specialisations for pointer types.
Where the pointers are implemented by a void* base implementation. (Done for vector)

Add UTF8 string class.