|
Boost : |
Subject: Re: [boost] Towards a Warning free code policy proposal
From: Mika Heiskanen (mika.heiskanen_at_[hidden])
Date: 2010-08-28 17:11:08
On Sat, 2010-08-28 at 22:17 +0300, Robert Ramey wrote:
> d) some were too hard to fix/eliminate comparison between signed/unsigned -
> I just left them because I didn't know how to fix them
Am I missing some complication I'm not aware of?
In my experience this warning is just about always the result of
using int for variables which should be of type size_t, as in
for(int i=0; i<object.size(); i++)
If I cannot redefine all the types to unsigned, something like this
usually fixes the problem:
if ( size >= 0 && static_cast<size_t>(size) < object.size() )
Writing static_casts is annoying, but it is often necessary
if you want to remain -Wall -pedantic.
--> Mika Heiskanen
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk