C++ Logo

std-proposals

Advanced search

Re: [std-proposals] auto[]

From: Zhihao Yuan <zy_at_[hidden]>
Date: Tue, 16 Jul 2024 18:46:59 +0000
On Tuesday, July 16th, 2024 at 5:14 AM, Данил Сидорук via Std-Proposals <std-proposals_at_[hidden]> wrote:

> I got that we can't just remove `T shall not be an array type` and make few changes in the next paragraph. Cause we can't deduce array type using the rules of template argument deduction from a function call with initializer list:
> #include <cstdio>
> template <class U>
> void f(U(&u)[]) {}
> int main() {
> f({1, 2, 3, 4, 5}); // Doesn't work
> }



The three major compilers agree that calling

template <class U>
void f(U(&&u)[]);
with that initializer list works. It seems that U(&)[]
does not work only because it cannot bind to an
array rvalue.

--
Zhihao

Received on 2024-07-16 18:47:09