Now that we have std::array what uses are left for C-style arrays?

arrays, c++, c++11, initialization

Solution

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::array` does allow static initialization, but it still won't count the initializers for you. And since the only real use of C style arrays before `std::array` was for statically initialized tables along the lines of:

MyStruct const table[] =
{
    { something1, otherthing1 },
    //  ...
};

using the usual `begin` and `end` template functions (adopted in C++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 have `std::array`.

Problem

`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?

Original source

Related problems