C++ Logo


Advanced search

Re: [wg14/wg21 liaison] Multidimensional subscript operator

From: Uecker, Martin <Martin.Uecker_at_[hidden]>
Date: Fri, 30 Apr 2021 07:32:38 +0000
Am Donnerstag, den 29.04.2021, 20:56 -0400 schrieb Bjarne Stroustrup:
> I'd express that as "C++ has tried to limit the use of built-in arrays
> to their natural domain of modeling fixed-sized contiguous sequences of
> objects in memory."

C++ also has


which also simple describes fixed-size contiguous sequences
of objects in memory.

I understand why one would like a type with more regular
syntax and properties which fit in better with template
mechanisms. But I wonder whether this needs to be a separate
and incompatible type? Also maybe C style arrays could
be made to fit in better with the rest of the types.

Then, of course, in C there are also arrays of run-time bound
which are extremely useful for bounds checking and multi-dimensional
array (some C++ compilers have them as extensions). Everything
proposal have seen for C++ so far which tries to address this
problem in a different way seems to be inferior to me.

Of course, one can always hide the length from the type
and then has a
dynamic array type with a hidden length
that can be interrogated at run-
time. But this has
different properties and use cases and will never
as light-weight and type safe as a type that
directly encodes this

The problem here is that in C++ there is
no way to express in the type system. There is simply no
way to work around this fundamental limitation using
library types.


> On 4/27/2021 5:15 PM, Ville Voutilainen via Liaison wrote:
> > C++ has been sidelining C arrays to a legacy
> > feature since the inception of std::vector.

Received on 2021-04-30 02:32:46