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


The containers in the ETL are designed to complement those found in the STL. The main difference is that their capacity is
defined at compile time and they contain their own storage. They do not allocate any storage from the heap at any time.
This is an advantage on an embedded device as all of the memory required by the application will be defined upfront. Also
due to the storage's contiguous nature, the containers are cache friendly.

Containers in the ETL library are mostly based around a common design theme of three classes.
(Where container is the name of the relevant container).

container<type, size>

etl::vector<type, size>

The container_base contains data and functions that are in independent of both the type and size.
This is inherited by icontainer<type> that implements functionality that is dependent on the type, but not the size.
Lastly, container<type, size> implements the small amount of functionality that requires both type and size

The classes do not implement any virtual functions and, like STL containers, are not normally expected to be used as base
classes  themselves.

Code using containers of a specific type can be written to be independent of the storage size through use of icontainer
class references.

container_base is also available as an interface, but unlikely to be of any practical use.


#include "vector.h"
#include "numeric.h"
#include <iostream>
#include <iterator>
#include <algorithm>

// Print takes a const reference to the interface container class.
void print(const etl::ivector<int>& v)
  std::copy(v.begin(), v.end(), std::ostream_iterator<T>(std::cout, " "));
  std::cout << "\n";

int main()
  // Declare the vector instances.
  etl::vector<int, 10> v1;
  etl::vector<int, 20> v2;

  etl::iota(v1.begin(), v1.end(), 0);
  etl::iota(v2.begin(), v2.end(), 10);

  print(v1); // Prints 0 through 9
  print(v2); // Prints 10 through 29

  return 0;