A lot of attention has been received by = default
and = delete
with respect to the special members (default constructor, destructor, copy and move). Can = default
and = delete
be used with other functions; member functions, free functions and operators etc.?
I can understand that = default
would probably not be allowed outside the special members; since it is basically saying use the compiler generated default. The default would need to be clearly defined before the compiler is able to generate it. As far as I know, only the special members have these pre-defined defaults.
What about = delete
; it is basically saying that the function is declared, but the implementation is explicitly not defined.
- Can
= delete
be used with functions other than the special members?
- What function types can it be used on (members, non-members, operators etc.)?
- Or conversely, where (or when) is
= delete
prohibited from being used? Are there any restrictions on its use?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…