I have this struct
struct A {
A() { cout << "Default\n"; }
A(const A& a) { cout << "Const lvalue\n"; }
A(const A&& a) { cout << "Const rvalue\n"; }
A(A& a) { cout << "Lvalue\n"; }
A(A&& a) { cout << "Rvalue\n"; }
};
which I'm using to understand rvalues/lvalues.
When doing
A a1;
A a2{ a1 };
const A a3;
A a4{ a3 };
It correctly outputs
> Default
> lvalue
> Default
> Const lvalue
The problem is that when I do something like
A a{ A() };
The output is Default. But isn't A()
an rvalue there? Shouldn't A::A(A&&)
or A::A(const A&&)
have to be called? what is happening here?