Thursday, December 12, 2013

FeedaMail: Comments for Sutter’s Mill

feedamail.com Comments for Sutter's Mill

Comment on GotW #91 Solution: Smart Pointer Parameters by CS

I work a large project that has legacy going back to the ’80s. Some of the code is Fortran, some C, but a large part is C++ and most of the new code is C++.
Some of the C++ is in an old style and some has been updated to a more modern style.

I come across a function with a pointer parameter:

  void DoSomethingAwesome(double *pVal);  

Is this a modern “Non-owning raw * pointer”? or is this a legacy “bad_sink” that should be updated?

If I’m lucky there is a comment somewhere that tells me, otherwise I need to search into the .cpp file and decide if this is a bad_sink and perhaps update it. (Of course pVal in this function could actually be used as an iterator with some fun old school pointer math going on.)

It would be very nice if the language had a feature that allowed functions to explicitly state “pass me a non-owning pointer”. As it is now all they can say is “trust me, do I look like I might delete your non-owning raw pointer?”

Read More »
 
Delievered to you by Feedamail.
Unsubscribe

No comments:

Post a Comment