std::array is vastly superior to the C arrays. And even if I want to interoperate with legacy code, I can just use std::array::data(). Is there any reason I would ever want an old-school array?
std::array is vastly superior to the C arrays. And even if I want to
Share
Unless I’ve missed something (I’ve not followed the most recent changes in the standard too closely), most of the uses of C style arrays still remain.
std::arraydoes allow static initialization, but it still won’t count the initializers for you. And since the only real use of C style arrays beforestd::arraywas for statically initialized tablesalong the lines of:
using the usual
beginandendtemplate functions (adopted inC++11) to iterate over them. Without ever mentionning the size, which the compiler determines from the number of initializers.
EDIT: Another thing I forgot: string literals are still C style arrays; i.e. with type
char[]. I don’t think that anyone would exclude using string literals just because we havestd::array.