etl-fixed-containers
:::warning [UNTESTED] on real silicon
Verified on native_sim only. ETL is header-only and portable; on-target the same #includes and API calls build and run unchanged.
:::
Fixed-capacity containers with no heap and no STL, via the vendored Embedded Template Library (ETL 20.39.4).
Source: examples/peripheral-io/etl-fixed-containers/.
What it does
Builds two fixed-capacity containers and exercises them:
etl::vector<int, 8>—push_back,size,capacity, and a range-for sum.etl::map<const char *, int, 4>—operator[]insert plus afind()lookup.
Capacity is part of the type, so all storage is inline — nothing reaches an allocator.
Why it matters on an MCU
The SDK builds M-class apps with no heap on the hot path and no exceptions. ETL is the direct answer to "I want std::vector semantics without std::vector's allocator":
prj.confdeliberately does not setCONFIG_REQUIRES_FULL_LIBCPP, so the example builds inETL_NO_STLmode.ETL_NO_EXCEPTIONSroutes over-capacity throughetl_error_handlerrather than throwing.
ETL is header-only, so it has no Kconfig knob of its own — libraries: [etl] just puts the vendored headers and the SDK's etl_profile.h on the include path.
board.yaml
libraries:
- name: etl
cores: [m55_hp]
som:
sku: E1M-AEN801
preset: e1m-evk
supported_boards:
- e1m-evk
- e1m-x-evk
cores:
m55_hp:
app: ./src
peripherals: []
diagnostics:
log_level: info
Pure logic — no peripherals, no chips.
Expected output
[etl-fixed-containers] vector: size=5 capacity=8
[etl-fixed-containers] vector: sum=15
[etl-fixed-containers] map: size=3
[etl-fixed-containers] map: lookup("b") = 2
[etl-fixed-containers] done
See also
fmt-formatting— the other header-only C++ library example- Examples overview