Classes and class hierarchies
C.32
If a class has a raw pointer (`T*`) or reference (`T&`), consider whether it might be owning
Reason
There is a lot of code that is non-specific about ownership.
Example
class legacy_class
{
foo* m_owning; // Bad: change to unique_ptr<T> or owner<T*>
bar* m_observer; // OK: keep
}
The only way to determine ownership may be code analysis.
Note
Ownership should be clear in new code (and refactored legacy code) according to R.20 for owning pointers and R.3 for non-owning pointers. References should never own R.4.
Enforcement
Look at the initialization of raw member pointers and member references and see if an allocation is used.