我正在使用Boost.program_options庫並需要指定具有Unicode支持的implicit_value。Boost.program_options:implicit_value和Unicode導致編譯時錯誤
對於ANSI字符串此代碼工作正常
po::options_description desc("Usage");
desc.add_options()
("help,h", "produce help message")
("-option,o", po::value<std::string>()->implicit_value(""), "descr");
但是,如果使用Unicode支持這樣
po::options_description desc("Usage");
desc.add_options()
("help,h", "produce help message")
("-option,o", po::wvalue<std::wstring>()->implicit_value(L""), "descr");
我收到以下錯誤:
boost/lexical_cast.hpp(1096): error C2039: 'setg' : is not a member of 'boost::detail::lexical_stream_limited_src<CharT,Base,Traits>'
boost/lexical_cast.hpp(1097): error C2664: 'std::basic_istream<_Elem,_Traits>::basic_istream(std::basic_streambuf<_Elem,_Traits> *,bool)' : cannot convert parameter 1 from 'base *' to 'std::basic_streambuf<_Elem,_Traits> *'
boost/lexical_cast.hpp(1103): error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::basic_istream<_Elem,_Traits>' (or there is no acceptable conversion)
我該怎麼做錯了?
請參閱http://stackoverflow.com/questions/6921196/in-boostprogram-options-how-to-set-default-value-for-wstring獲取解釋和修復。 –
Sahab Yazdani,謝謝。 – vkrzv