vendredi 6 mars 2020

Runtime array bounds on stack as per c++ draft

As per my understanding based on previous readings, array size needs to be constant and known at compile time with exception to additional support provided by g++ where VLA are supported.

However I was going through one of the c++ draft and now I am confused, does c++ support runtime array bounds. They have given the below code example for defining the array.

C++ draft link: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3690.pdf

Section 8.3.4

Eg:

void f(unsigned int n) {
int a[n]; // type of a is “array of runtime bound of int”
}

Aucun commentaire:

Enregistrer un commentaire