Finding an alphanumeric character in a string using find_if and isalnum

后端 未结 3 1175
小蘑菇
小蘑菇 2020-12-22 05:53

I\'m using g++ 4.7.

What I\'m trying to do is this,

find_if(s.begin(), s.end(), isalnum);

where isalnum

相关标签:
3条回答
  • 2020-12-22 06:28

    This should work.

    #include <algorithm>
    #include <cctype>
    auto result = std::find_if (begin(s), end(s), std::isalnum);
    
    0 讨论(0)
  • 2020-12-22 06:41

    This should work

    #include <algorithm >
    #include <cctype>
    
    auto result = std::find_if(std::begin(s), std::end(s),  isalnum) ;
    
    0 讨论(0)
  • 2020-12-22 06:47

    The compiler is having trouble disambiguating between this function and this function. You want the first one, and you'll have to help the compiler out here, by specifying the signature with a cast:

    find_if(s.begin(), s.end(), (int(*)(int))isalnum);
    
    0 讨论(0)
提交回复
热议问题