Consider this:
struct Man
{
operator int const& () const& { return m_ban ; }
operator int && () && { return std::move(m_ban); }
int m_ban;
};
void ff(int const& ) { std::cerr << "==== void ff(int const& )" << std::endl; }
void ff(int &&) { std::cerr << "==== void ff(int &&)" << std::endl; }
And later:
Man man;
ff(static_cast<Man const& >(man));
ff(static_cast<Man &&>(man));
This perfectly works with gcc-8.3.0
, but gcc-9.3.0
and all versions of clang
and msvc
can't pick the right ff
for the second call. Is this a compiler bug? How the code should behave according to the standard?
Indeed, both type operators can be called for Man&&
:
static_cast<Man&&>(man).operator int const& ();
static_cast<Man&&>(man).operator int &&();
But because of the ref-qualification, the second one should be picked during the implicit conversion, right?
Aucun commentaire:
Enregistrer un commentaire