"However, I am a bit puzzled about the question, what is it that can be done more efficient / easier with arrays rather than with containers?"
Well, if you're referring to c-style arrays, with the current c++ standard, there's nothing left about the disadvantages of the classic standard c++ container classes (like e.g. std::vector
) IMHO. These have a dependency to have allocatable memory (with new()
), and that could well be be a restriction for your current (OS/bare metal) environment, as not being available out of the box.
The current standard provides std::array
, that works without dynamic memory allocation needs, but fulfills all of the claims:
"1. subscripts are not checked"
std::array
does subscript checking
"2. often it is required to allocate memory from the heap"
It's the client's choice where it's actually allocated with std::array
. std::vector
suffices anyway for doing this.
"3. not easy to insert elements in the middle"
Well, that's one point not supported well by std::array
out of the box. But again, std::vector
and other container classes support this well (as long your environment supports dynamic memory allocation)
"4. always passed as reference"
std::array
supports passing by reference well, and much better than it can (can't) be achieved with c-style arrays.
Though there may be specialized cases for e.g. reusable object instance pools, or flyweight object instances, you might want to solve using the placement new()
operator. Implementations for such solutions, usually would involve you're going to operate on raw c-style arrays.