C++ Logo


Advanced search

Re: [std-proposals] The Oxford variadic comma

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Fri, 1 Mar 2024 12:39:57 -0500
On Fri, Mar 1, 2024 at 12:34 PM Jan Schultke <janschultke_at_[hidden]>

> > Uh, why not? Is there a particular reason why it's important to allow
> omitting the comma specifically here?
> Because this is an abbreviated variadic function template.
> If f(auto... x) is a variadic function template, removing x should
> result in a function template with the same type. This is the case in
> the current draft, it's totally fine, I'm happy with it, and I'm not
> deprecating it.

Hmm, did you misread the line? It was this:

void f(auto x ...) // deprecated, equivalent to f(auto,...)

This is not an abbreviated variadic template; it's an abbreviated
non-variadic template with an ellipsis parameter.

    void f(auto... xs); // is a parameter pack
    void f(auto xs...); // is an ellipsis parameter without comma, and I
(and apparently Barry :)) want it deprecated plz

There's no reason for anyone to write
    void f(auto xs...);
intentionally. Those programmers whose intention matches the compiler's
interpretation (hopefully very rare) should instead write
    void f(auto xs, ...);
to be explicit about their intentions. Meanwhile, the vast majority of
programmers who write it by accident should be safely guided by compiler
diagnostics toward what they actually meant, which is highly likely to be:
    void f(auto... xs);


Received on 2024-03-01 17:40:10