Embedded C++, memory management and containers

Hi,

I've been searching the internet for this for a while, but I could not find anything that fits my needs. So Here's my question :
does anybody knows about a C++ library that :
- provides STL-like containers (vector, map, set, ...)
- allows fine memory management required by embedded software programs (e.g. STL vectors are likely to grow dynamically : it is forbidden)
- avoids as much as possible copy-constructors. STL copy-contructs almost each time an element is insterted in a container. The most common workaround is to use pointers, but in that case, memory management is not performed by the container itself. A solution here is to use placement new, but it is not easy with templates (is it possible to use class-specific constructor in a templated container ?).

I got interested in ETLCPP (http://www.etlcpp.com/home.html) but copy-contructors are used just like STL does.

Any idea ?

Regards

Nei
> allows fine memory management required by embedded software programs
> (e.g. STL vectors are likely to grow dynamically : it is forbidden)

std::array is a fixed size container with a standard container-like interface.
http://en.cppreference.com/w/cpp/container/array

For other containers, we can provide a custom allocator.
http://en.cppreference.com/w/cpp/memory/allocator


> avoids as much as possible copy-constructors.

The standard library containers do avoid copying objects as much as possible.

For example, push_back of an rvalue into a vector would move construct if the type is nothrow_move_constructible
For example, overload (2) http://en.cppreference.com/w/cpp/container/vector/push_back

The emplace family of functions construct the objects in-place within the container.
For example: http://en.cppreference.com/w/cpp/container/vector/emplace_back
+1 for allocators, that's what I used back when I worked in embedded field
Topic archived. No new replies allowed.