|
Boost : |
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-10-30 02:25:26
>"Dave Gomboc" <dave_at_[hidden]> wrote in message
news:002b01c39ea4$8595fb90$fb01a8c0_at_cyborg...
> > so where should I use unsigned?
> >
> > -Thorsten
>
> Use unsigned numeric types whenever negative values aren't
> permitted or don't make sense.
>
When I read up on the matter in these theads
I don't agree. AFAICT, we should stick to signed and check ranges.
>From what I can remember in the threads:
1) some sompilers might warn, not all will.
2) the burden of the checking functions precondition is put onto the user
3) a range check can still be done on the unsigned type, but it must be
converted to a signed first
4) we can't get rid of signed, but we can get rid of unsigned in many places
5) mixing signed and unsigned has many pitfalls
6) overloading on unsigned can easier lead to ambiguity than signed
7) the mixin of signed an unsigned is a problem for beginners
8) range checks are mostly not critical for program performance
9) experts advocate signed (Bjarne Stroustrup, Francis Glassborrow, James
Kanze, Scott Meyers)
I would be good if boost could agree on some guidelines for this.
best regards
Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk