2
是否可以使用本地類作爲std :: find_if的謂詞?您可以使用函數本地類作爲謂詞find_if?
#include <algorithm>
struct Cont
{
char* foo()
{
struct Query
{
Query(unsigned column)
: m_column(column) {}
bool operator()(char c)
{
return ...;
}
unsigned m_column;
};
char str[] = "MY LONG LONG LONG LONG LONG SEARCH STRING";
return std::find_if(str, str+45, Query(1));
}
};
int main()
{
Cont c;
c.foo();
return 0;
}
我得到GCC以下編譯器錯誤:
error: no matching function for call to 'find_if(char [52], char*, Cont::foo()::Query)'
每個人都可以看到你的編輯歷史,所以沒有必要寫在你的文章的額外評論說你編輯的內容。 – 2011-06-15 14:19:48