Apr 7, 2021 at 11:40pm UTC
I do not understand how a copy ctor can be deprecated when either of the special functions mentioned is user declared...
How can the compiler create the copy ctor from the destructor for instance?
From the assignment operator that seems doable but not from the destructor.
Any light on this?
Apr 8, 2021 at 3:12am UTC
Currently the C++ compiler will
write a copy constructor and copy assignment operator for you
if you provide a destructor. This behavior is deprecated, but copy constructors aren't deprecated otherwise.
The intent is to support the rule of three
Which implies that if a class needs a user-declared destructor, it needs to have "custom" copy functions or have
no copy functions at all
Last edited on
Apr 8, 2021 at 3:14am UTC