我正在尝试使用regex_match()
作为count_if()
中的谓词,其中vector<string>
元素用于类成员函数中。但不知道如何正确绕过第二个参数(正则表达式值)到函数中。 是否有办法使用regex_match()
作为谓词(例如bind1st()
)?regex_match作为谓词
int GetWeight::countWeight(std::regex reg)
{
std::cout << std::count_if(word.begin(),word.end(),std::bind1st(std::regex_match(),reg)) << std::endl;
return 1;
};
字 - 是我需要来算匹配std::regex reg
元素绕过类的外部vector<std::string>
。
如果签名不匹配正好,你不能插上直接..虽然答案下面看起来不错。 – xaxxon