class A
{
public:
A(int n = 0) : m_n(n) { }
A(const A &a) : m_n(a.m_n) { }
A(A&& rval) : m_n(rval.m_n) { }
A& operator= (A&& rval) { }
A& operator= (const A& source) { m_n = source.m_n; return *this; }
~A() { }
private:
int m_n;
};
int main()
{
A a = 2;
}
I expected the line A a = 2; to call Ctor(int), then move operator, but actually move doesnt get called and none of the defined operators is called instead. Why is that, how is the temporary assigned to the actual a object?
It's obvious that second one will call only A(int), but the first one seems like it would also need to call a copy ctor to copy the temporary into a object thats beaing created ?