1
我知道我能做到這一點:調用內部STD功能:: all_of
vector<int> insidetest;
if(std::all_of(insidetest.begin(),insidetest.end(),[](int i){return i>100;}))
{
std::cout << "All greater" << std::endl;
}
但我想調用其他職能(也許不僅僅是> 1000更復雜)。我如何可以調用的std :: all_of內的另一個功能,例如:
bool fun(const vector<int> *s)
{
return true;
}
目前尚不清楚你想要做什麼。傳遞給'std :: all_of'的參數將是'typename Container :: value_type'(在本例中爲'int'),所以使用一個帶有'const向量 * s'的函數是沒有意義的。 –
Yuushi
2013-04-22 06:04:42
你是不是指在傳遞給'std :: all_of'的lambda中調用'fun'? – 2013-04-22 06:06:25
這是我的錯誤。我讀到:「謂詞函數的簽名應該等價於:bool pred(const Type&a)」,所以在我的情況下,我認爲它是const vector *。現在我明白它是如何工作的 –
2013-04-22 06:08:52