将向量或参数传递给boost :: process(boost :: fusion)

时间:2017-12-04 10:22:58

标签: c++ boost boost-fusion boost-process

我试图从字符串参数向量创建boost::process

void runProcess( const std::string& exe, const std::vector<std::string>& args )
{
    bp::ipstream out;
    bp::child c(exe, args, std_out > out);
    ...
}

这显然有效,但我收到以下警告:

  

警告C4503:&#39; boost :: fusion :: detail :: for_each_linear&#39;:超出装饰名称长度,名称被截断

如果逐个传递参数bp::child c(exe, "param1", "param2", std_out > out);,它就会消失。

在这种情况下调用child构造函数的正确方法是什么?

1 个答案:

答案 0 :(得分:2)

您可以按预期使用:

bp::child c(bp::search_path("ls"), bp::args({"-1", "-l"})/*, ...*/);

在你的情况下可能像

void runProcess( const std::string& exe, const std::vector<std::string>& args )
{
    bp::ipstream out;
    bp::child c(exe, bp::args(args), std_out > out);
    ...
}