2 ms·
> raw pointers are now code smell The way I look at it is that something has to own the pointer. That ownership should be expressed via std::unique_ptr. If own
by criddell 5y ago
> raw pointers are now code smell
The way I look at it is that something has to own the pointer. That ownership should be expressed via std::unique_ptr. If ownership must be shared (which is relatively rare) or you need weak pointers (even more rare), then use std::shared_ptr.
It's not a code smell to receive a pointer parameter because the function or method doesn't own the pointer. I would generally pass const references as parameters except for those cases where you may want to allow a nullptr parameter.