3 ms·
"get any senior dev to move away from using references instead of const pointers." ... "the reader has no idea whether the argument will be modified or not with
by fsloth 3y ago
"get any senior dev to move away from using references instead of const pointers."
...
"the reader has no idea whether the argument will be modified or not without reading the header file."
It sounds like the problem is not using an IDE.
Use references whenever posssible. Then you don't need to do a null pointer check. C++ is a footgun. And like with all guns, security first. With guns - put the safety on. With C++ - check the pointers are not null.
OFC one can argue that with proper instrumentation invalid pointers are captured sooner than later, but the fact is it's much easier to represent invalid program state using pointer than references.
- thecodedmessage 3y agoYes, the "C++ is not usable on its own and needs other tools" defence of C++ :-)
- PaulDavisThe1st 3y agoIn my experience (31 years of C++) it is much more likely that problematic pointers will be non-null but also invalid.