I know references are preferred over pointers, but it is very tedious to change all those "." to "->" when needed. So is it an acceptable practice to always use pointers instead of references, to be easily convert them to smart pointers if needed? Or is there any way to quickly change a reference to pointer?
So is it an acceptable practice to always use pointers instead of references, to be easily convert them to smart pointers if needed
No. In general, always rules are always bad. (including this one). Why would you want to convert a reference to a smart pointer? If it's a reference, you don't need to worry about memory management, and that's the purpose of a smart pointer.
Or is there any way to quickly change a reference to pointer?
Yes, taking it's address (&
).
Change the architecture just to facilitate text replacements in source code?
No, this is never a valid design decision. And as Luchian has explained, this doesn’t seem like a really existing consideration to begin with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With