11

以下の私のコードは機能しませんでした:

wstring config_file;
// Declare a group of options that will be 
// allowed only on command line
po::options_description generic("Generic options");
generic.add_options()
    ("help,h", "produce help message")
    ("config,c", po::wvalue<wstring>(&config_file)->default_value(L"DXDrv.cfg"), "name of a file of a configuration.")
    ;

コンパイルはエラーで失敗しました:

d:\ repo \ a4x_ext \ minidxdriver \ testapp \ configparser \ boost \ lexical_cast.hpp(1096):エラーC2039::はの'setg'メンバーではありません'boost::detail::lexical_stream_limited_src<CharT,Base,Traits>'

4

1 に答える 1

16

長い説明:これは、の基になるtyped_value型がプライベートメンバーの設定でからへprogram_optionsの字句キャストを実行しようとするためです。何らかの理由で、basic_stringタイプには、正しいテンプレートタイプを作成するために必要な関数がありません。wcharcharm_default_value_as_text

幸い、typed_valueクラスには、default_valueとimplicit_valueの2番目のオーバーライドがあり、値の文字列表現を提供します。これは、問題を修正するlexical_castをバイパスします。何かのようなもの:

     tvalue< tstring >()->default_value( _T( "output.png" ), "output.png" )
于 2011-12-18T03:28:40.963 に答える