[Bug c++/83445] conversion function has too high priority in overload resolution

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Aug 18 09:48:20 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83445

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Invoking Target(Source const&) is a user-defined conversion too. The conversion
sequence requires binding a reference to the Source object and then converting
it to a Target.

In C++17 there is no call to Target(Target const&) or Target(Target&&) because
the temporary returned by Source::operator Target() is materialized directly
into an object of type Target.

Clang agrees with GCC that Source::operator Target() is a better conversion,
but I can't find the wording specifying that.


More information about the Gcc-bugs mailing list