C++14: Runtime-sized arrays

More details on the ISO C++ blog about runtime-sized arrays in C++14.

N3639 proposes to add local runtime-sized arrays with automatic storage duration to C++, for example:

void f(std::size_t n)
{
int a[n];
for (std::size_t i = 0; i < n; ++i)
{
a[i] = 2*i;
}
std::sort(a, a+n);
}

Traditionally, the array bound “n” had to be a constant expression.

2 Comments

Filed under C++, Programming

2 responses to “C++14: Runtime-sized arrays

  1. Pingback: Runtime-sized arrays v std::dynarray in C++ 14 | musingstudio

  2. Pingback: C++14 Language Extensions | musingstudio

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.