D
D
Daniil Demidko2016-03-17 11:18:22
C++ / C#
Daniil Demidko, 2016-03-17 11:18:22

{} when initializing an array of arrays?

Why does this compile with -c++11:

int x=2, y=5;
int arr[x][y]{};

And with -c++14 not?
And if you remove {} , then everything is compiled with -c++14 ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MiiNiPaa, 2016-03-17
@Daniro_San

In general, it shouldn't compile at all. Array sizes must be constant expressions.
What you have is a compiler extension. Doesn't work in C++14, most likely because in C++11 the compiler uses its own extension based on C++ VLAs. And in C++14, there are more limited C++ ARBs that could have been included in C++14 but weren't.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question