Is the Rule of 5 (for constructors and destructors) outdated, if smart pointers can take care of resource management?

The full name of the rule is the rule of 3/5/0.

It doesn’t say “Always provide all five”. It says that you have to either provide the three, the five, or none of them.

Indeed, more often than not the smartest move is to not provide any of the five. But you can’t do that if you’re writing your own container, smart pointer, or an RAII wrapper around some resource.

Leave a Comment