Declaring a special member function with ``++private++`` or ``++protected++`` visibility and no definition was standard practice before {cpp}11 to prevent the function from being generated by the compiler in order to prevent copy or assignment operations, for example.


Unfortunately, this purpose is not clearly expressed by such function declarations, leaving maintainers to check that such functions are not defined or used in the ``++private++`` or ``++protected++`` scopes.


{cpp}11 adds the ability to explicitly ``++delete++``, or prevent the generation of, individual special member functions without affecting any of the others. Not only is this new syntax cleaner, but it's also clearer to maintainers.


This rule raises an issue when any of the following is declared with less than ``++public++`` visibility and not defined or not used:

* default constructor
* move constructor
* move-assignment operator
* copy constructor
* copy-assignment operator


== Noncompliant Code Example

----
struct Book {
  // ...
private:
  Book(const Book &Other);       // Noncompliant
  Book &operator=(const Book &); // Noncompliant
};
----


== Compliant Solution

----
struct Book {
  // ...
private:
  Book(const Book &Other) = delete;
  Book &operator=(const Book &) = delete;
};
----



ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
