First of all, choosing std or juce containers should both be safe in terms of stability.
But as you mentioned both,
std::array I think we have to differentiate between dynamic containers using heap memory and static containers using stack memory.
Dynamic containers can modify their size at runtime. A dynamic container is basically just some metadata like a size and a pointer to some memory. If you tell it to change the size, it will automatically allocate some heap memory, take care to copy the content it already holds over to that new location, safely delete the old chunk of memory and also safely delete its memory on destruction.
std::vector and ´juce::Array` are dynamic containers that work like that. The underlying memory management techniques differ a bit and the one might be faster than the other, depending on your use case, but I don’t think that it’s that relevant in a lot of real-world scenarios.
Fixed size containers like
std::array work differently. You define its size at compile time and the object will always contain the whole memory internally instead of just a pointer to some external heap memory location.
Both types of containers have their pros and cons. Dynamic containers give you the flexibility of not needing to know the size of the container as a compile time constant. On the other hand, fixed size containers are faster to create and destroy, as they don’t do memory management, they simply increase/decrease your stack pointer which is super fast. Creating temporary dynamic containers during an audio processing routine is a no-go as the allocation performed is a system call with a non-deterministic return time, so here you only want to use fixed size containers as temporarily created objects. The same goes for high performance graphics rendering. But once you set the size on your dynamic container and don’t change it, accessing the data held in it is as fast as accessing data in a fixed size container, so a common practice is to keep dynamic containers as class member, set their size before processing starts and then re-use them without changing their size. Another downside of huge stack based objects like a huge
std::array is that stack size is limited – you can create a stack overflow with too big stack objects.
Now if you ask for the availability of
juce::vector, what kind of functionality are you looking for that
juce::Array doesn’t have?