This snippet is compiled without errors in Visual Studio 2013 (Version 12.0.31101.00 Update 4)
class A
{
public:
A(){}
A(A &&){}
};
int main(int, char*)
{
A a;
new A(a);
return 0;
}
while it is compiled with this error in Visual Studio 2015 RC (Version 14.0.22823.1 D14REL):
1>------ Build started: Project: foo, Configuration: Debug Win32 ------
1> foo.cpp
1>c:\dev\foo\foo.cpp(11): error C2280: 'A::A(const A &)': attempting to reference a deleted function
1> c:\dev\foo\foo.cpp(6): note: compiler has generated 'A::A' here
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I think that the compiler shipped with Visual Studio 2015 generates the Copy Constructor and marks it as =delete
and so I get the error C2280 (which, by the way, I cannot find documented on msdn.microsoft.com).
Now, let's say I have a codebase which is compilable with Visual Studio 2013 (and it works because it relies on the code generated automatically by the compiler) but not compilable with Visual Studio 2015 due to C2280, how can I fix the problem?
I was thinking to declare class A
in this way:
class A
{
public:
A(){}
A(A &&){}
A(const A&)=default;
};
am I missing something?
A& operator=(A&&) ;
andA& operator=(const A&);
– Jagannath