Boost logo

Boost :

From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2007-05-08 18:17:22


On 5/8/07, Mathias Gaunard <mathias.gaunard_at_[hidden]> wrote:
> Dean Michael Berris wrote:
> > I still think the
> > semantics of `lexical_cast<int8_t>("127")` should allow for the
> > conversion to happen -- either convert to a 'short int' then assign to
> > a char, if that makes any sense.
>
> There is no way to distinguish int8_t and char. They are both aliases to
> the same type.
> Welcome to the wonderful world of typedefs.
>

Perhaps is there was a specialization for lexical_cast<int8_t> and/or
lexical_cast<char> which implemented the "correct" behavior as the
semantics for lexical_cast suggest (not an expert with cross platform
types, but I'm guessing 'short int' will always be 8 bits, unless I'm
missing something), maybe this will "just work"?

I tried looking at the code which involves lexical_cast, but I'm
seeing too much BOOST_PP_* stuff that I currently don't have the
bandwidth for.

Any pointers on how to make that happen? Or would leaving it alone and
saying in the docs that this isn't going to happen correctly be
enough?

-- 
Dean Michael C. Berris
http://cplusplus-soup.blogspot.com/
mikhailberis AT gmail DOT com
+63 928 7291459

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk