[pkg-boost-devel] Bug#412931: libboost-dev: allow lexical_cast to handle based number strings

LI Daobing lidaobing at gmail.com
Thu Mar 1 01:43:23 CET 2007


On 3/1/07, Wesley J. Landaker <wjl at icecavern.net> wrote:
> Package: libboost-dev
> Version: 1.33.1-10
> Severity: wishlist
>
> Please allow lexical_cast to handle based number strings. Currently,
> it only supports decimal strings, but it should be able to handle octal
> and hexadecimal strings if they have correct prefix notations.
>
> Background:
> This happens because lexical_cast constructs a stringstream, which by
> default has the ios_base::dec flag set. If this flag is unset, it will
> still read decimal strings, but will also automatically determine the
> base by looking at the prefix, so will read decimal strings if the
> number starts with 0-9, octal if it starts with 0, and hex if it starts
> with 0x.
>
> Fix:
> After constructing the stringstream, simply call
> stringstring::unsetf(std::ios_base::basefield). Because decimal numbers
> are still handled correctly, this is totally backwards compatible.
>
> This is a really simple thing to fix, but if you need any help
> implementing it, I would be happy to provide a real patch.
>
>
>
It's better to post this to boost's develop maillist.


-- 
LI Daobing




More information about the pkg-boost-devel mailing list