【问题标题】:Boost: is_any_of generates multiple errorsBoost: is_any_of 产生多个错误
【发布时间】:2013-10-08 01:03:37
【问题描述】:

我刚刚安装了 boost,到目前为止我使用的所有功能都运行良好,但是当我使用 trim_if 时,当你需要使用 boost::is_any_of 时,它产生了多个错误。

这是我遇到的一些错误:

error C2868: 'std::iterator_traits<_Iter>::iterator_category' : illegal syntax
for using-declaration; expected qualified-name

error C2825: '_Iter': must be a class or namespace when 
followed by '::'

error C2602: 'boost::range_iterator<C>::type' is not a member of a base class 
of 'boost::range_iterator<C>'

error C2602: 'std::iterator_traits<_Iter>::iterator_category' 
is not a member of a base class of 'std::iterator_traits<_Iter>'

error C2039: 'iterator_category' : is not a member of '`global namespace''

我尝试重新安装 boost,但没有成功。

代码:

#include <iostream>
#include <string>

#include <boost/algorithm/string.hpp>

int main(int argc, char *argv[])
{
    std::string string = "\t\tthis is a string\t";

    boost::trim_if(string, boost::is_any_of('\t'));

    std::cout << string << std::cout;

    system("pause");
    return 0;
}

【问题讨论】:

    标签: c++ boost iterator trim


    【解决方案1】:

    您的问题在于电话boost::is_any_of('\t')

    is_any_of 接受一系列字符,而您传递的是单个字符。

    将您的代码更改为:

         boost::trim_if(string, boost::is_any_of("\t"));
    

    即,使用双引号而不是单引号。

    【讨论】:

    • 好的,我明白了。谢谢!
    猜你喜欢
    • 2011-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-15
    • 2019-12-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多