Boost logo

Boost Users :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-06-02 19:52:20


Delfin Rojas wrote:
>> -----Original Message-----
>> On Behalf Of Jonathan Turkanis
>> 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.

> 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.

The global C++ locale can contain user-defined facets, so the C locale cannot
always be made to match the C++ locale.

> 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...

Jonathan
> -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