Date: Wed, 13 Aug 2025 14:50:29 +0200
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.
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.
Jens
> 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.
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.
Jens
Received on 2025-08-13 12:50:33