【发布时间】:2013-01-14 16:19:19
【问题描述】:
这基本上是我想做的:
bool special_compare(const string& s1, const string& s2)
{
// match with wild card
}
std::vector<string> strings;
strings.push_back("Hello");
strings.push_back("World");
// I want this to find "Hello"
find(strings.begin(), strings.end(), "hell*", special_compare);
// And I want this to find "World"
find(strings.begin(), strings.end(), "**rld", special_compare);
但不幸的是,std::find 不能这样工作。那么只使用 STL,我怎么能做这样的事情呢?
【问题讨论】:
-
附注 - 比较中的字符串参数应该是
const string&而不仅仅是string&。顺便说一句,有趣的问题。