boost:program_options を使用したコマンド ラインの解析に問題があります。それを説明する最も簡単な方法は、コードを次のように示すことです。
const std::vector<tstring> args;
if (ac > 0 && NULL!=av) //ac is a ULONG
{
for (int i = 0; i < ac; i++)
{
args.push_back(av[i]); //av is an LPTSTR pointer (pointer to TCHAR*)
}
}
po::command_line_parser parser(args);
パーサー ctor は const std::vector<charT> を取ることになっています
typedef basic_command_line_parser<char> command_line_parser;
typedef basic_command_line_parser<wchar_t> wcommand_line_parser;
/** Creates instance of 'command_line_parser', passes parameters to it,
and returns the result of calling the 'run' method.
*/
template<class charT>
class basic_command_line_parser : private detail::cmdline {
public:
/** Creates a command line parser for the specified arguments
list. The 'args' parameter should not include program name.
*/
basic_command_line_parser(const std::vector<
std::basic_string<charT> >& args);
私のプログラムのtstringは
typedef std::basic_string<TCHAR> tstring;
私が得るエラーは次のとおりです。
Error 16 error C2664: 'boost::program_options::basic_command_line_parser<charT>::basic_command_line_parser(const std::vector<_Ty> &)' : cannot convert parameter 1 from 'const std::vector<_Ty>' to 'const std::vector<_Ty> &' myfile.cpp 329
どこへ どこへ行くの? あらゆる種類のキャストと再定義を試みましたが、何も機能せず、テザーの終わりにいます。
@Zac を編集:
あなたが提案した変更を行っています... エラーが表示されます:
Error 14 error C2664: boost::program_options::basic_command_line_parser<charT>::basic_command_line_parser(const std::vector<_Ty> &)' : cannot convert parameter 1 from 'std::vector<_Ty>' to 'const std::vector<_Ty> &' MyFile.cpp 328
編集 Visual Studio 2008 VC9 コンパイラを使用していることを指摘するだけです