C++ Logo

std-discussion

Advanced search

Re: Not understanding rvalue reference matching rules in overloaded functions.

From: Andrew Schepler <aschepler_at_[hidden]>
Date: Tue, 1 Jun 2021 13:08:06 -0400
On Tue, Jun 1, 2021 at 12:44 PM Edward Catmur via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> The types int&, int&&, int correspond perfectly well to int lvalue, int
> xvalue, int prvalue, so it's reasonable to describe - as a shorthand - an
> expression with type int and value category xvalue as having type int&&.
>

Sometimes, maybe, and it does have the benefit of brevity. But when
interpreting the Standard, it's important to remember that anywhere it says
"the type of [an] expression", this type is not a reference type. And
determining the behavior of tricky overload resolution cases is a scenario
where we do want to be very technical and precise. Though a downside of
common use of the shorthand is that it can lead others to misinterpret
parts of the Standard if they don't know this rule.

Received on 2021-06-01 12:08:20