C++ Logo

std-proposals

Advanced search

Re: [std-proposals] default, delete, and auto for templates and other contexts

From: mauro russo <ing.russomauro_at_[hidden]>
Date: Fri, 15 Nov 2024 11:22:25 +0100
hello,

in https://lists.isocpp.org/std-proposals/2024/11/11517.php I tried to
propose extended usage of default, delete, auto, likely a too long post.

Therefore, let me restrict here below the third part I consider more
interesting:

A way to allow parameter packs not to be the last for a main template,
based on 'auto' used as explicit template argument

declaration:
template<typename... T, typename... U>
void f(T... t, U... u);

invocation:
f<auto...[2]>(1, 'b', 2.);

forced to deduce only two parameter types for the first parameter pack.


An extended use may be:
declaration:
template<typename V, typename W>
void g(V v, W w);

invocation:
g<auto, char>(1, 'b');

which will force second parameter as char, while leaving first parameter to
be deduced.

It is a kind of 'default deduction'.

Then auto[N] may be a syntax sugar in place of repeating "auto," N times in
case the (N+1)-th parameter has to be explicit.

In case, "auto..." would be a redundant option to use for the last
parameter pack.

Not sure where "auto" (instead of "auto...") should work also for (the
last) parameter pack.

Is this 'defaulted' behaviour considered evil as default parameter values
for functions ?

Received on 2024-11-15 10:22:40