|
Boost : |
From: Bjorn.Karlsson_at_[hidden]
Date: 2002-06-17 14:45:05
> From: Samuel Krempp [mailto:krempp_at_[hidden]]
[snip]
> But by the way, does boost provide functions for integral types
> conversion that checks against over-limit numbers ?
> or is there a std:: way to do it, that I don't know ?
> for instance, I'm always uncomfortable casting an unsigned to signed.
> Taking the habit of static_cast'ing types without checking
> for possible
> over-limit problems can cause unnecessary risks of obscure failures,
> sooner or later, when we do reach the limit..
Boost.Conversion contains a very handy tool for this - numeric_cast. It is
slightly broken as of now, but it still makes sense to use it. An improved
version is on the rise, with correct behavior, an optimized implementation
and added features (thanks to Fernando Cacciola).
Bjorn
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk