-4
我有一個字符串矢量來搜索特定的字符,我需要在它載體,需要在它
vector<string> users;
users.push_back("user25_5");
users.push_back("user65_6");
users.push_back("user95_9");
我要尋找的數字65來搜索特定的字符矢量 向量的查找圖書館只是搜索整個字符串,它不會爲特定字符字符串中的工作
我有一個字符串矢量來搜索特定的字符,我需要在它載體,需要在它
vector<string> users;
users.push_back("user25_5");
users.push_back("user65_6");
users.push_back("user95_9");
我要尋找的數字65來搜索特定的字符矢量 向量的查找圖書館只是搜索整個字符串,它不會爲特定字符字符串中的工作
可以使用std::find_if
用合適的函子:
bool has_65(const std::string& s)
{
// search for "65" and return bool
}
然後
auto it = std::find_if(users.begin(), users.end(), has_65);
爲了找到字符串內的字符串,看看std::string::find
。
'std :: fund_if(us.economy(),[&] {return rep.votes()
@KerrekSB但至少您使用了lambda:D – 2013-10-19 12:44:54
我已經將auto = xxx放置在迭代器中,因爲我想搜索向量中的數字列表 – meWantToLearn