3 ms·
> "classes should not define any of the special functions (copy/move constructors/assignment, and the destructor) unless they are classes dedicated to resource
by MichaelMoser123 11y ago
> "classes should not define any of the special functions (copy/move constructors/assignment, and the destructor) unless they are classes dedicated to resource management."
All C++ classes are dedicated to managing the memory resource that they are allocated on, am i missing something?
- goldfire 11y agoThe rule is saying that a class which does explicit resource management should be doing only resource management and have no other behavior. In other words, only wrapper classes should manage the resource they wrap, and (ideally) no other resource management should exist. That keeps the management work out of the way of other classes.
- jblow 11y agoAnd this leads to code that is either too complex, too inefficient, or both. I mean it's fine if you are competing with Python or something ,but if you actually care about perf this is never going to work. But of course anyone wanting to coin a "Rule of X" doesn't want to see a problem in its full context, they just want to be able to pretend to have a solution well enough that they can at least fool themselves. Etc, etc.