
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Scott McMurray Sent: Wednesday, November 18, 2009 3:19 PM To: boost@lists.boost.org Subject: Re: [boost] [new Warnings policy] MS C4180 on the Maintenance Guidelines
2009/11/18 Paul A. Bristow <pbristow@hetp.u-net.com>:
I note that this will mean quite a lot of work for some people as "if (ptr)
..."
is such a common (and IMO dreadful) idiom.
What do you propose as a superior idiom that will work with pointers, smart pointers, optional, ...?
Slapping double-exclamation points everywhere is no better.
!! is not mentioned in the draft Guidelines, following feedback. The 'safe bool' idiom http://www.artima.com/cppsource/safebool.html might be, but that may be getting into too much detail. I am proposing if (prt != 0) { ...// do something with pointer as it is meaningful. } As several people have observed, this expresses exactly what you mean, showing that prt == 0 is a special case, rather than saving a few keystrokes. It may be obvious for pointers, but having an 'invalid or special' value is used widely elsewhere. Or if that is considered too much work, suppressing the warning (locally to that module). Let's not flagellate ourselves too much over this ;-) Paul --- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow@hetp.u-net.com