C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Tue, 11 Oct 2022 09:52:11 +0100
On Sun, Oct 9, 2022 at 1:30 PM Arthur O'Dwyer via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> void f(int&&) { puts("int"); }
> void f(double&&) { puts("double"); }
>
> int main() {
> int i = 1;
> double d = 2;
> f(i); // prints "double"
> f(d); // prints "int"
> }


Please give me a web link, or a short explanation, of why this code
behaves the way it does.

Received on 2022-10-11 08:52:24