Implicit array size in C ++ 11 is similar to C arrays

In C ++, you can say this:

int xs[] = { 1, 2 };

      

Here the size of the array can be inferred at compile time to two, so there is no need to explicitly say:

int xs[2] = { 1, 2 };

      

Is there an equivalent to the first construct using C ++ 11 arrays - a way to define one without explicitly specifying the size? Maybe something like this:

array<int, _> xs = { 1, 2 };  // does not compile

      

instead of specifying:

array<int, 2> xs = { 1, 2 };

      

+3


source to share





All Articles