Despite the multiple questions about performance\benefits\properties of std::array vs std::vector or C style array, I still never got a clear answer about actual practical usage and types of problems that can be (and should be solved with std::array). the reason i am asking is because me myself and in all the projects that i was working in C++ i never saw any usage of std::array but most of the work done with std::vector, is some are cases we used std:deque.
After compering the properties seems like array is something in the middle that like a C style array that have a thin(not so thin - have a lot of APIs) layer of abstraction but not heavy as std::vector. feel like if performance really matter or i have limitation because of embedded device i would still use C style array.
I tried to compare some other relatively large C++ project for example Notepad++ source code, and they very seldom use std::array only in json.hpp which is third party of its own, so to summarize
What are actual practical usage that can be solved by std::array better then other STL or native array?
is it possible that modern C++ compiler can optimize away all the abstraction leaving it basically like native C array.
I noticed in json.hpp that used by notepad++ source code that std::array used with char_traits and templates, is it possible that std::array can be used in implementation of other Libraries that are using templates and template meta-programming heavily while native C array would require more adapters or workaround that have performance penalty?
EDIT: I understand that std::array properties like fixed size and the sizes is known, but why it is still relatively seldom used.
Thanks a lot :)
std::arrayis defined as an aggregate, overhead should be minimal (if any) over C-style array. Unless you of course copy it by accident, because you replacedvoid foo(int* arr)withvoid foo(std::array<int, 5>)without any second thought.std::array