Boost logo

Boost Users :

Subject: Re: [Boost-users] Unicode option in program_options
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2010-08-14 01:04:40


John Dlugosz wrote:

>> > see reference to class template instantiation
>> 'boost::program_options::typed_value<T,charT>' being compiled
>> > with
>> > [
>> > T=std::wstring,
>> > charT=char
>> > ]
>>
>> You should consider po::wvalue<> template function.
>
> Thanks Mickaël, that is better.
>
> So, why does po::value<T> work for whatever type I want my parameter to be

Not really -- it works for whatever type you can extract out of stringstream,
not whatever type.

> _except_ for wstring,

and wstring cannot be extracted from stringstream.

> which needs to use po::wvalue<T> instead?
>
>
> ("datadir",
> po::wvalue<std::wstring>()->default_value(std::wstring(L"."),"."),
> "the directory")
>
> Now getting default_value to work with that was some trial and error. It didn't take L".", which
> is exactly what parse_command_line is going to be finding were it not the default. I would expect
> a token in either wide or narrow forms to work, and give the same results as those tokens would if
> found in the argv array.

default_value is another victim of the fact that wstring cannot be converted to string. I am
not sure much can be done on program_options side.

- Volodya


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