#include <iostream>
struct A
{
void f() const &
{
std::cout << "A::f()&" << std::endl;
}
void f() const &&
{
std::cout << "A::f()&&" << std::endl;
}
};
struct B
{
void f() const &
{
std::cout << "B::f()&" << std::endl;
}
};
int main()
{
A{}.f();
B{}.f();
}
The output is:
A::f()&&
B::f()&
Note that void B::f() const &&
doesn't exist.
My questions is:
Why is void B::f() const &
chosen when void B::f() const &&
is not present?
Aucun commentaire:
Enregistrer un commentaire