I have seen in a few places the recommendation to use std::array
over C-style arrays in C++, claiming it is a better, safer alternative with no overhead. See:
The standard container array [...] has no space overheads beyond what it needs to hold its elements, [...]. In other words, it is very much like a built-in array without the problems. (C++11 FAQ)
However, as I understand it, being a template container there will be an overhead as far as program size goes, since it will generate code for every different N an array is instanced with.
Suppose my program uses std::array
in various places with several different integers for N, will this lead to bloated code? Is it negligible?
Should I worry about this for non-type template parameters in general?