Subject: Re: [boost] [new Warnings policy] MS C4180 on the MaintenanceGuidelines
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2009-11-17 17:57:25
John Maddock wrote:
>>> Looks OK to me but anyone 'deprecating' this before I add it to the
>>> Are we sure that all compilers can evaluate this as compile time -
>>> while debugging users might find it a pest?
>> While this is a a workaround that disables the warning, I personally
>> find it almost unreadable, and wouldn't want to encourage it's usage.
>> In my mind when I see a ! I think "not", and have to always apply
>> extra brain power to realise there are 2, and what it means.
> Me too.
And me too.
However due to coding styles I've been using I'm getting used to it.
> I accept that this idiom has it's uses though - for example where the
> type being tested has an operator !() but no direct conversion to bool -
> although the "safe bool conversion idiom" used in Boost and elsewhere is
> IMO superior to this.
> What's wrong with using either x != 0, or x == 0, depending on which
> result you want? It's pretty explicit , and exactly mirrors what the
> compiler has to do internally to convert x to a bool in the first place?
Nothing wrong for me personally, but I've heard some say it's too long
and unnecessary as in assert(0 != ptr) all 5 characters can
be replaced with just one !
I prefer explicit version - code for people first, then for computers.
-- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk