A replacement for std::bind2nd

前端 未结 3 869
轻奢々
轻奢々 2021-01-01 22:41

I have a foo which is a std::vector. It represents the \"edge\" values for a set of ranges.

For example, if foo is

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-01 22:57

    bind version would be:

    bind(std::greater(), placeholders::_1, bar)
    

    but I think, it is more encouraged to use lambdas, as in:

    [bar](const int a){return bar < a;}
    

    It is also encouraged to use overloaded functions begin/end instead of method calls. so it would be like:

    find_if(begin(foo), end(foo), [bar](const int a){return bar < a;})
    

提交回复
热议问题