C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Specify that argument to function cannot be an rvalue

From: Thiago Macieira <thiago_at_[hidden]>
Date: Tue, 11 Oct 2022 09:08:59 -0700
On Tuesday, 11 October 2022 04:30:52 PDT Ville Voutilainen via Std-Proposals
wrote:
> void f(int&&) { puts("int"); }
> void f(double&&) { puts("double"); }
>
> so
>
> int i = 1;
> f(i);
>
> prints "double", because it can't call void f(int&&). Instead, it'll
> convert the int to double,
> and call void f(double&&).

But why can't it convert int to int and then call the int&& overload?

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2022-10-11 16:09:07