Initializing multiset with custom comparison function in C++

前端 未结 4 1375
独厮守ぢ
独厮守ぢ 2021-02-04 14:50

Consider following comparison function:

bool compare(std::shared_ptr &lhs, std::shared_ptr &rhs){
   return lhs->val         


        
4条回答
  •  长发绾君心
    2021-02-04 15:27

    decltype(compare)* in the template parameter specifies the type of the comparator. It doesn't tell which function is to be used - whether is it compare, foo, bar or something else. Hence the constructor parameter.

提交回复
热议问题