This is supposed to be a trivial question but I could not find it explicitly on stackoverflow.
The following will be defined implicitly if not provided by the user.
But I have read somewhere (which I cant seem to find now), that there are some conditions where the compiler will not implicitly implement them.
What are these conditions?
The Default Constuctor (e.g., X()
) will not be implicitly generated if:
const
object, or a class with no or inaccessible default constructor)X() = delete;
The Copy Constructor (e.g., X(const X&)
) will not be implicitly generated if:
X
a constructor taking X
, X&
or const X&
) X(const X&) = delete;
The Copy Assignment Operator (e.g., X& operator=(const X&)
) will not be implicitly generated if:
X
an operator=
taking X
, X&
or const X&
)const
object, or a class with no or inaccessible assignment operator)X& operator=(const X&) = delete;
The Destructor (e.g., ~X()
) will not be implicitly generated if:
~X() = delete;
The Move Constructor (C++11) (e.g., X(X&&)
) will not be implicitly generated if:
X
, a constructor taking X&&
)const
, is a reference, or has a deleted, inaccessible, or ambiguous move constructor)X(X&&) = delete;
The Move Assignment Operator (C++11) (e.g., X& operator=(X&&)
) will not be implicitly generated if:
X
, an operator=
taking X&&
)const
, is a reference, or has a deleted, inaccessible, or ambiguous move assignment operator)X& operator=(X&&) = delete;