我正在使用g ++ 4.7。使用find_if和isalnum在字符串中查找字母數字字符
我想要做的就是這個,
find_if(s.begin(), s.end(), isalnum);
其中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>)’
然而,這個工作,
bool my_isalnum(int c) {
return isalnum(c);
}
find_if(s.begin(), s.end(), my_isalnum);
我怎樣才能得到這個沒有創造我自己的函數工作?
如果C++ 11適合您,您可以使用lambda表達式。 – jogojapan
它適用於我的VS2012 – billz