使用bind()函数为find_if()传递参数

 

bool check_size(string s, int sz)
{
    return s.size() >= sz;
}

int main() {
    vector<string> strs = { "axx", "css", "bww", "ssdde", "awweerf" };
    int sz = 4;
    auto f1 = bind(check_size, placeholders::_1, placeholders::_2);
    auto wc = find_if(strs.begin(), strs.end(), bind(check_size, placeholders::_1, sz));
    cout << *wc;
    return 0;
}

 

posted @ 2021-01-10 00:10  zeroPatrick  阅读(122)  评论(0编辑  收藏  举报