Is this a technical requirement that it cannot be done by the compiler in any way or pure security-wise suggestion that is enforced?
-
5What do you mean by "special member functions"? Can you please show an example (with code) what you mean? – Some programmer dude Mar 17 '14 at 10:09
-
It is a set of rules of the language, mainly to make it hard to implicitly generate badly behaving code. But it is not as simple as you state. Explicitly declaring *some* special member function *can* disable generation of *some* of the other ones. – juanchopanza Mar 17 '14 at 10:10
-
Search for The Rule Of Three/Five – Manu343726 Mar 17 '14 at 10:43
-
I know the conditions and I know the rule of three/five. I am asking what the reason behind it is. – Etherealone Mar 17 '14 at 11:58
-
This is not a duplicate. I am not asking the conditions. I am asking the reason of those conditions. – Etherealone Mar 17 '14 at 14:32
1 Answers
No, the reason is not technical.
The auto-generated special member functions are designed to act somewhat like POD/C-style struct
similar operations, but extended. This makes C++ types act slightly more uniformly.
But not all types should behave that way. C++ stops auto generating some according to rules set down in the standard for purely language/code design reasons -- it was decided removing them was better than leaving them in to be called by surprise or through inexperience. Probably had the language been designed today, the rule or 3/5 would be explicit in how member function auto generation is implicitly disabled.
C++11 adds =default
as a way, among other things, to bring them back.
Move special member functions both had to deal with C++03 backward compatibility, and not breaking existing code. There is no technical barrier here either, just language design and backward compatability issues.

- 262,606
- 27
- 330
- 524