From: Martin (adrianm_at_[hidden])
Date: 2004-09-21 05:06:57
> It's already the case, because config file do not contain the information
> about the used locale. Further, even if it did, the set of locales on
> different computers is not the same, and on different OS even the naming
> may be different, so moving configuration files is hard already.
> This might mean I need to set classic locale for parsing, to make sure
> config files are really portable.
I am not familiar with the code layout for program options but with a quick
look it seems like you can do it the the same way as in the streams? Add a
locale reference member to the value_semantics class and an imbue method to
the options_description class which specifies the default.
The user can then specify exactly how he wants the options:
max portablity: desc.imbue(std::locale::classic())
localized: desc.imbue(std::locale()) // should be default
> That's not convenient, so probably global
> "lexical_cast_locale" is better. But for MT environment you need to store
> that global state in TSS.
The global locale can already be used so there is no need for another global
const std::locale old = std::locale::global(std::locale::classic());
double x = lexical_cast<double>(str);
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk