码迷,mamicode.com
首页 > 其他好文 > 详细

functor

时间:2015-10-27 13:20:03      阅读:195      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!