C++ Logo

std-discussion

Advanced search

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

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Tue, 1 Jun 2021 17:22:18 +0100
On Tue, 1 Jun 2021 at 14:55, Edward Diener via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> Since std::move creates an rvalue reference and one of the overloads to
> afunc takes an rvalue reference, for an exact match, I do not understand
> the error. Would someone please explain and cite the section of the
> C++11 standard which explains why the exact match is an equal match to
> the other overload, thereby causing ambiguity ?
>

The two standard conversion sequences are int&& -> int&& (identity) and
int&& -> int (lvalue-to-rvalue conversion). The latter conversion is an
Lvalue Transformation [over.ics.scs], which is excluded from consideration
by [over.ics.rank]/3.2 item 1.

Received on 2021-06-01 11:23:00