首页 > 其他 > 详细

functor

时间:2015-10-27 13:19:19      阅读:237      评论:0      收藏:0      [点我收藏+]

I thought it would be easy and convenient to define a small functor and perform a customized sort on some objects I have. However, I can‘t seem to get the functor to work. Here is some code that gives me a "no matching call" error:

class Cmp
{
    bool operator()(int x, int y) const
    {
        return x < y;
    }
};

vector<int> vec;
std::sort(vec.begin(), vec.end(), Cmp() );


As far as I can tell I followed the requirements exactly, but apparently I didn‘t. Can anyone tell me what is wrong with the above code? Thanks for your time.

functor

原文:http://www.cnblogs.com/zhoug2020/p/4913694.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!