3

In C++ you can say the following:

int xs[] = { 1, 2 };

Here the size of the array can be inferred at compile time to be 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

rather than having to specify:

array<int, 2> xs = { 1, 2 };
stanm
  • 3,201
  • 1
  • 27
  • 36

0 Answers0