Skip to content

Instantly share code, notes, and snippets.

@mrdomino
Last active October 24, 2015 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrdomino/b90d78a00e9bc7e85f0d to your computer and use it in GitHub Desktop.
Save mrdomino/b90d78a00e9bc7e85f0d to your computer and use it in GitHub Desktop.
copy and assignment operator autogeneration
class A {};
class B {
public:
B() = default;
B(B const&) = delete;
};
class C {
public:
C() = default;
C(C const&) = delete;
C& operator=(C const&) = delete;
};
class D {
public:
D() = default;
D& operator=(D const&) = delete;
};
int main() {
A a1;
A a2(a1);
A a3; a3 = a1;
B b1;
//B b2(b1); // nope
B b3; b3 = b1;
C c1;
//C c2(c1); // nope
//C c3; c3 = c1; // nope
D d1;
D d2(d1);
//D d3; d3 = d1; // nope
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment