【问题标题】:Cannot get boost header to compile无法获取 boost 标头进行编译
【发布时间】:2015-08-11 05:45:13
【问题描述】:

我想使用 Boost 库来拆分字符串,但在使用 Visual Studio 时出现编译错误。

我的代码有#include "boost/algorithm/string/split.hpp";#include "boost/algorithm/string/classification.hpp";,我项目的包含目录包含C:\Data\Libraries\Boost_1.56.0,它本身包含带有Boost 头文件的根boost 目录。

然后我有以下内容:

std::string line = "this,is,a,test";
std::vector<std::string> strings;
boost::algorithm::split(strings, line, boost::is_any_of(','));

但这给了我各种各样的错误,例如:

Error   37  error C2039: 'type' : is not a member of 'boost::mpl::eval_if_c<false,boost::range_const_iterator<char,void>,boost::range_mutable_iterator<char,void>>' C:\Data\Libraries\Boost_1.56.0\boost\range\iterator.hpp 69

有什么帮助吗?

【问题讨论】:

    标签: c++ boost


    【解决方案1】:

    该消息令人困惑,因为它基本上是发脾气的模板元编程,但问题是boost::is_any_of(',') 无法编译,因为',' 是不能被视为“范围”的单个字符。

    你的意思是写:

    boost::algorithm::split(strings, line, boost::is_any_of(","));
    //                                                      ^ ^
    

    【讨论】:

      【解决方案2】:

      您尝试使用boost::algorithm::split(strings, line, boost::is_any_of(","));Here 是使用split 函数的另一种解释。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-07-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-09-06
        相关资源
        最近更新 更多