
Hi,
The following example could not be compiled: ================================================================= #include <string> #include
namespace po = boost::program_options;
int main() { std::wstring test; po::options_description desc("Allowed options"); desc.add_options() ("test", po::wvaluestd::wstring(&test)->default_value(L"value"), "description"); } ================================================================= It is due to wvalue::default_value tries to do lexical_caststd::string(std::wstring). Also I cannot change default_value to default_value("value") as soon as it accepts only something convertible to std::wstring. In other words it is impossible to specify default_value for wstring option. I've solved this by providing alternative value description in a char-based encoding. In my case, I use UTF-8 for all descriptions, and filter all output of boost::program_options through UTF8->wchar_t conversion.
So in your case desc.add_options() ("test", po::wvaluestd::wstring(&test)->default_value(L"value", "value"), "description"); will probably compile fine. However, I agree that this is a bug - wvalue should probably use wstringstream and not stringstream for conversions. I also think that other classes like options_descriptions should accept wide strings, because otherwise we need to use the UTF8 trick to enable localization of these. Moreover, some english strings seem to be hard-coded in program_options (exception messages, etc.) There should be another way of handling cmdline errors - we can't presume that the user understands english text. And there does not seem to be a way of translating the po exceptions to localized strings without accessing/changing some po internals. Hope this helps, Filip