C++ Logo

liaison

Advanced search

Re: [isocpp-wg14/wg21-liaison] VLA notation in parameter

From: Martin Uecker <ma.uecker_at_[hidden]>
Date: Wed, 13 Aug 2025 15:44:06 +0200
Am Mittwoch, dem 13.08.2025 um 14:50 +0200 schrieb Jens Maurer:
>
> On 13.08.25 10:45, Martin Uecker wrote:
> > Am Dienstag, dem 12.08.2025 um 23:23 +0200 schrieb Jens Maurer:
> > >
> > > On 12.08.25 09:35, Martin Uecker wrote:
> > > > Yes. Sorry, I wasn't clear. My point was that if you wanted
> > > > to avoid the "template" notation and write this with "auto"
> > > > like this
> > > >
> > > > void foo(std::array<float, sizeof(b)>, auto b);
> > > >
> > > > this would not work.
> > >
> > > At least the first mention of "b" would not refer to the
> > > second parameter, but maybe to a "b" introduced in the
> > > surrounding scope somewhere.
> > >
> > > > But my impression was that C++ is
> > > > moving towards this nicer way of writing templates.
> > >
> > > C++ is offering this as a short-hand, but I'm not seeing
> > > a tidal move in this direction. Being able to refer to
> > > the name of a template parameter (e.g. for constraints)
> > > is useful in a lot of situations. Also, I haven't
> > > seen much use of "auto" parameters in recent library
> > > proposals accepted into C++.
> >
> > So would you say the template syntax that forwards declares
> > the typename is good enough?
>
> There is not really a "forward" declaration here
> (in the sense that a "real" declaration follows).
> The "template<typename B>" declares the type B;
> the "B x" that follows declares a variable "x" of type B;
> those are different things.

Of course. It declares the type B. The effect is that it
is accessible at a point before it would usually be possible
to access the type of 'x'.

>
> Personally, I would be fine with "auto" parameters not existing
> in C++, but they're part of the standard now, so my opinion
> doesn't matter.
>
> I just tried to respond to "C++ is moving towards this",
> a statement for which I'm not seeing good evidence.
>
Thanks for clarifying.

Martin

Received on 2025-08-13 13:44:09