Subject: Re: [boost] [new Warnings policy] MS C4180 on the Maintenance Guidelines
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2009-11-18 05:48:53
> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On
> Patrick Horgan
> Sent: Tuesday, November 17, 2009 7:59 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] [new Warnings policy] MS C4180 on the Maintenance
I've tried to distill the many helpful comments on this as follows:
||C4800|| int' : forcing value to bool 'true' or 'false'||
Use a bool valued expression.
Write out expressions, for example: "value >= 0" or "ptr != 0" (Boost prefers
clarity to curtness).
Take care if using templates that constants are of the right type, for example
you may need "static_cast<T>(1)".
Or use static_cast<bool>(expression).
||# pragma warning(disable: 4800) // int' : forcing value to bool 'true' or
Hope this is better.
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.
So I've left the getout clause "suppress" as a last resort.
But this might encourage people to write new code in a nicer way.
--- Paul A. Bristow Prizet Farmhouse Kendal, UK LA8 8AB +44 1539 561830, mobile +44 7714330204 pbristow_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk