C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] Multidimensional subscript operator

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Mon, 26 Apr 2021 18:45:12 +0300
On Mon, 26 Apr 2021 at 18:37, Uecker, Martin
<Martin.Uecker_at_[hidden]> wrote:
> > 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?

Yeah. http://c-faq.com/decl/spiral.anderson.html

> 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.

You need a typedef for every function declaration that uses an array as a return
type. Or, like P1997 suggests, you need to use a trailing return type.
That's not what I'd call regular.

> Otherwise I find
>
> int a[3][4];
>
> a lot easier to read than
>
> std::array< std::array< int, 4 >, 3 > a;

That's why we are adding mdspan.

> 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.

I'm happy to agree to disagree with that.

Received on 2021-04-26 10:45:26