C++ Logo


Advanced search

Re: [wg14/wg21 liaison] Multidimensional subscript operator

From: Uecker, Martin <Martin.Uecker_at_[hidden]>
Date: Mon, 26 Apr 2021 15:37:00 +0000

Am Montag, den 26.04.2021, 18:20 +0300 schrieb Ville Voutilainen via
> On Mon, 26 Apr 2021 at 17:56, will wray via Liaison
> <liaison_at_[hidden]> wrote:
> > > I'm not sure why that matters. C++ array-ish types are very
> > > different
> > > from C arrays, leaving C arrays the odd and irregular corner
> > > case.
> > How are they "very different"? Should they be?
> They compare and copy like normal objects do, and there's no decay in
> them.
> Their declarations do not require understanding a "spiral rule".

What is the "spiral rule"?

Do you mean C's strange declarator syntax?

This has not much to do with array types: It is the
same for functions and can easily be avoided
using typeof when it becomes too complex.
Otherwise I find

int a[3][4];

a lot easier to read than

std::array< std::array< int, 4 >, 3 > a;


> > C array is a rough cut gem with sharp edges that cut.
> > Let's polish a beautiful, pure, elemental aggregate.
> C++ already has that, as std::array.
> > It matters because C array matters, and not just to C.
> > And not just to the 'numerical matrix' few who need multi-index.
> > Lack of safe buffer handling causes continued pain and damage,
> > to the detriment of C and C++ reputation.
> C++ has safe buffer handling, as std::vector.
> You're more than welcome to try improving C arrays to be usable
> without all of their problems.

I have to say that I find C arrays extremely useful,
relatively simple, and the recursive design quite
elegant. In fact, it is one of the main reason
I prefer to use C over C++ for all my scientific code.

There are some loose ends and quirks, but nothing
which would justify the bad reputation they seem
to have in C++ circles.


Received on 2021-04-26 10:37:08