我正在嘗試使用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