I'd like to find out why the code below doesn't compile with C++14, but compiles fine with C++17. Any ideas what could be changed since C++17? The thing is of course about non-const copy constructor of a class A. I am using VS 2019. Is this code valid at all?
class A {
public:
A() { }
A(A& a) { }
};
A fun() {
A a;
return a;
}
int main()
{
A a = fun();
}
Messages from the compiler:
- class A has no suitable copy constructor
- initializing cannot convert from A to A
- Cannot copy construct class A due to ambiguous copy constructors or no available copy constructor