要对vector中的自定义类型进行排序,首先需要提供一个函数bool comp(const Interval & a, const Interval & b) 来定义类型的排序准则

然后调用std::sort(intervals.begin(),intervals.end(),comp)  写了几个小的测试用例也都通过了,但是当集成在类中的时候编译遇到问题,

Line 30: no matching function for call to 'sort(std::vector<Interval>::iterator, std::vector<Interval>::iterator, <unresolved overloaded function type>)'

刚开始以为是类型不对,改用指针也不行,换用qsort进行排序也不行,折腾了好长时间终于找到资料http://blog.csdn.net/flybywind/article/details/7536311

原来当comp作为类的成员函数时,默认拥有一个this指针,这样和sort函数所需要使用的排序函数类型不一样。解决方法是将comp改为非成员函数,或者改用静态函数。

vector排序问题<unresolved overloaded function type>的更多相关文章

  1. Qt error ------ no matching function for call to QObject::connect(QSpinBox*&, <unresolved overloaded function type>, QSlider*&, void (QAbstractSlider::*)(int))

    connect(ui->spinBox_luminosity,&QSpinBox::valueChanged, ui->horizontalSlider_luminosity, & ...

  2. Faiss in python and GPU报错:NotImplementedError: Wrong number or type of arguments for overloaded function 'new_GpuIndexFlatL2'.

    最近在玩faiss,运行这段代码的时候报错了: res = faiss.StandardGpuResources()flat_config = 0index = faiss.GpuIndexFlatL ...

  3. error C2556: 'const char &MyString::operator [](int)' : overloaded function differs only by return type from 'char &MyString::operator [](int)'

    char & operator[](int i);const char & operator[](int i);/*const char & operator(int i);* ...

  4. 函数重载二义性:error C2668: 'pow' : ambiguous call to overloaded function

    2013-07-08 14:42:45 当使用的函数时重载函数时,若编译器不能判断出是哪个函数,就会出现二义性,并给出报错信息. 问题描述: 在.cpp代码中用到pow函数,如下: long int ...

  5. ptxas fatal : Unresolved extern function Error 255

    This question already has an answer here: External calls are not supported - CUDA 1 answer I am tryi ...

  6. [TypeScript] Define a function type

    type DigitValidator = (char) => boolean; -]{}/.test(char); export const digitValidators: {[key: s ...

  7. [Typescript] What is a Function Type ? Function Types and Interfaces - Are They Related ?

    Function Type: type messageFn = (name: string) => string; function sayHello(name: string): string ...

  8. 微信小程序官方文档中表单组建button部分有关function(type)中type的个人理解

    官方文档关于button组件的简介 xml页面挺容易理解,但js部分起初对整体写的形式都不太理解,随着逐渐阅读代码基本理解了 xml页面代码: <button type="defaul ...

  9. [TypeScript] Infer the Return Type of a Generic Function Type Parameter

    When working with conditionals types, within the “extends” expression, we can use the “infer” keywor ...

随机推荐

  1. 停掉一台服务器,Nginx响应慢(转载)

    测试发现的问题及解决办法 1.当后端两台IIS应用服务器都正常时,访问速度非常快,查看日志,原来一个请求,是后端两台服务器同时响应的; 2.为了模仿故障测试,停掉一台IIS应用服务器,这时再访问,请求 ...

  2. spring in action 7.2 小结

    1 对于二进制文件上传功能的实现.在spring中使用multipart来处理,处理方式有两种. CommonsMultipartResolver:使用Jakarta Commons FileUplo ...

  3. 419. Roman to Integer【medium】

    Given a roman numeral, convert it to an integer. The answer is guaranteed to be within the range fro ...

  4. print()函数的end 参数

    print()函数含end参数时:结束的时候已什么结尾,后面的参数可以是任何形式 [print() 默认以'\n'  结尾] 输出结果:  print()函数不含end参数时: 输出结果:

  5. CSS3多背景应用

    /*多背景应用*/ .wrapper { width: 640px; height: 1000px; margin: auto; background: url(./images/head.jpg) ...

  6. Ubuntu12.04 修复GRUB

    电脑安装了双系统,本来好好的GRUB管理启动,在重装过之后就只能进win7了,所以尝试将GRuB重新安装到mbr,使用GRUB作为启动管理程序. 1.制作U盘系统 使用软碟通,讲Ubuntu12.04 ...

  7. 浅谈weblogic与tomcat的区别

    weblogic是用于开发.集成.部署和管理大型分布式web应用.网络应用和数据库应用的java应用服务器,将java的动态功能和java enterprise标准的安全性引入大型网络应用的开发集成部 ...

  8. Hbase分布式安装部署过程

    系统 Red hat linux 6.4 Hadoop版本 1.2.1 Hbase版本 0.94.16 Hbase的完全分布式安装概述: 1. 配置hosts,确保涉及的主机名均可解析为ip 2. 编 ...

  9. Storm手写WordCount

    建立一个maven项目,在pom.xml中进行如下配置: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:x ...

  10. Linux用ssh登陆出现“Too many authentication failures for root”

    vim /etc/ssh/sshd_config 最后参数 UseDNS no AddressFamily inet PermitRootLogin yes SyslogFacility AUTHPR ...