title: C++ Compiler Error C2280 "attempting to reference a deleted function" in Visual Studio 2013 and 2015
body: <p>This snippet is compiled without errors in Visual Studio 2013 (Version 12.0.31101.00 Update 4)</p>
  
  <pre><code>class A
  {
  public:
     A(){}
     A(A &amp;&amp;){}
  };
  
  int main(int, char*)
  {
     A a;
     new A(a);
     return 0;
  }
  </code></pre>
  
  <p>while it is compiled with this error in Visual Studio 2015 RC (Version 14.0.22823.1 D14REL):</p>
  
  <pre><code>1&gt;------ Build started: Project: foo, Configuration: Debug Win32 ------
  1&gt;  foo.cpp
  1&gt;c:\dev\foo\foo.cpp(11): error C2280: 'A::A(const A &amp;)': attempting to reference a deleted function
  1&gt;  c:\dev\foo\foo.cpp(6): note: compiler has generated 'A::A' here
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>I think that the compiler shipped with Visual Studio 2015 generates the Copy Constructor and marks it as <code>=delete</code> and so I get the error C2280 (which, by the way, I cannot find documented on msdn.microsoft.com).</p>
  
  <p>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?</p>
  
  <p>I was thinking to declare class <code>A</code> in this way:</p>
  
  <pre><code>class A
  {
  public:
     A(){}
     A(A &amp;&amp;){}
     A(const A&amp;)=default;
  };
  </code></pre>
  
  <p>am I missing something?</p>