相关疑难解决方法(0)

使用find_if和isalnum在字符串中查找字母数字字符

我正在使用g ++ 4.7.

我想要做的就是这个,

find_if(s.begin(), s.end(), isalnum);
Run Code Online (Sandbox Code Playgroud)

其中isalnum在所定义cctype并且s是一个字符串.

logman.cpp:68:47: error: no matching function for call to ‘find_if(std::basic_string<char>::const_iterator, std::basic_string<char>::const_iterator, <unresolved overloaded function type>)’
Run Code Online (Sandbox Code Playgroud)

但是,这有效,

bool my_isalnum(int c) {
    return isalnum(c);
}

find_if(s.begin(), s.end(), my_isalnum);
Run Code Online (Sandbox Code Playgroud)

如何在不创建自己的功能的情况下使其工作?

c++ string stl g++

0
推荐指数
1
解决办法
2767
查看次数

标签 统计

c++ ×1

g++ ×1

stl ×1

string ×1