Boost logo

Boost Users :

From: Delfin Rojas (drojas_at_[hidden])
Date: 2005-06-02 19:11:44


> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Jonathan Turkanis
> Sent: Thursday, June 02, 2005 1:48 PM
> To: boost-users_at_[hidden]
> Subject: [Boost-users] Re: lexical_cast
>
> ian whittley wrote:
>
> > int to(std::string const& arg, Type2Type<int> const&)
> > {
> > return atoi(arg.c_str());
> > }
>
> This won't reflect the global C++ locale.
>
> Jonathan
>

Please forgive my ignorance if I'm wrong but I thought the C++ locale
underneath calls ::setlocale to set the global C locale and then ::atoi uses
the LC_NUMERIC category of the current C locale so everything should be fine
locale-wise. In fact I thought the conversion through std::stringstream ends
up using std::num_get which ends up using ::strtoul.

On the other hand, can boost::lexical_cast accept a hex string and correctly
convert it to its numeric representation? If so the ::atoi shortcut would
not work...

-delfin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net