Boost logo

Boost :

Subject: Re: [boost] Towards a Warning free code policy proposal
From: Mika Heiskanen (mika.heiskanen_at_[hidden])
Date: 2010-08-31 10:42:38

On Tue, 2010-08-31 at 17:06 +0300, Peter Bartlett wrote:
> On the issue of a casting between signed and unsigned types (error
> 4244 in VC), I am a bit concerned I am missing something. Why is there
> significant discussion about choosing which cast to make the warning
> go away? I am labouring under the impression that boost::numeric_cast
> was invented to do those conversions?

numeric_cast will throw if the cast is not safe, and sometimes that
is not what you want. There may be legacy design decisions involved
which you may not be able to change, such as using negative numbers to
indicate special conditions for a variable which is normally unsigned,
and the special condition may not indicate an error, but a case you just
have to handle separately.

--> Mika Heiskanen

Boost list run by bdawes at, gregod at, cpdaniel at, john at