So basically this code:
class A {
};
class B {
B (const B& b) {}
public:
B (){}
B (const A& a) {}
};
int main()
{
A a;
B b1(a); //OK
B b2 = a; //Error
}
only generates an error for B b2 = a
. And that error is
error: ‘B::B(const B&)’ is private
Why is it attempting to call the copy constructor in addition to the direct conversion constructor?
It's clear from the error message that a temporary B
is created which is then used for copy-construction, but why? Where is this in the standard?