简体   繁体   English

boost :: bad_any_cast:使用boost :: any_cast的转换失败

[英]boost::bad_any_cast: failed conversion using boost::any_cast

I am using boost V1.53 program_option like this.. 我正在使用Boost V1.53 program_option这样。

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include "linked_list.h"
#include <map>
#include "stdList.h"
#include "vector.h"
#include "set.h"
#include "AVL.h"
#include <boost/program_options.hpp>


using namespace std;
namespace po = boost::program_options;

int main(int argc ,char* argv[])
{
    ifstream dictionary, text;
    ofstream output;
    string dictionaryFile, textFile, outputFile,dtStructure;


    po::options_description desc("Allowed options");
    desc.add_options()
    ("DataStructure, s", po::value<string>()->required(), "Specify datastructure")
    ("Dictionary, d", po::value<string>()->required(), "Specify dictionary")
    ("TextFile, t", po::value<string>()->required(), "Specify textfile")
    ("Output, o", po::value<string>()->required(), "Specify output file");

try
{

    po::variables_map vm;
    po::store(po::parse_command_line(argc, argv, desc), vm);
    po::notify(vm);
    const string dtStruct=vm["DataStructure"].as<string>();
    cout <<"data is " <<dtStruct <<endl;


}
catch (const exception &e)
{
    cerr <<e.what()<<endl;
    return EXIT_FAILURE;
}
------and more code------

however, when i compiled .\\output --DataStruture a.dat --Dictionary dict --TextFile small --Output. 但是,当我编译。\\ output --DataStruture a.dat --Dictionary dict --TextFile small --Output时。 file 文件

it shows a boost::bad_any_cast: failed conversion using boost::any_cast 它显示了boost :: bad_any_cast:使用boost :: any_cast转换失败

any idea why? 知道为什么吗?

代码正确无误-您在命令行上拼写了错误的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 boost:bad_any_cast: 使用 boost:any_cast 错误的转换失败 - boost:bad_any_cast: failed conversion using boost:any_cast error 使用boost程序选项时如何解决“boost::bad_any_cast:使用boost::any_cast转换失败”的问题? - How to solve “boost::bad_any_cast: failed conversion using boost::any_cast” when using boost program options? 提升程序选项抛出 bad_any_cast 异常 - boost program options throwing bad_any_cast exception 如何将:: any_cast提升为std :: string - How to boost::any_cast into std::string clang编译的程序在std :: any_cast期间抛出std :: bad_any_cast - clang compiled program throws std::bad_any_cast during std::any_cast 将Boost类型的已擦除类型转换回原始类型可以给我boost :: bad_any_cast - converting boost type erased type back to original type gives me boost::bad_any_cast 可以提升:: any_cast <double> (any&)被加速? - Can boost::any_cast<double>(any&) be sped up? boost :: any_cast - 仅在隐式转换不可用时抛出? - boost::any_cast - throw only when an implicit conversion isn't available? 使用程序选项c ++进行boost :: any_cast抛出 - boost::any_cast throw with program options c++ 将 std::any_cast 与 decltype 一起使用...为什么此代码会抛出错误的 any_cast? - Using std::any_cast with decltype ... why does this code throw a bad any_cast?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM