要对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. blender, 创建多边形面片

    按a键清除所有选择,进入Edit Mode,选vertex select方式.然后按住control,使用MLB连续画多个顶点,形成一个多边形,如图所示: 然后同时选中两个端点,点Make Edge/ ...

  2. C# 文件与二进制互转数据库写入读出

    //这个方法是浏览文件对象 private void button1_Click(object sender, EventArgs e) { //用户打开文件浏览 using (OpenFileDia ...

  3. iOS之美: UIView 与 UIWindow之间的关系

    转自:http://leopard168.blog.163.com/blog/static/168471844201381584533466/ 面对iOS初学者,总会被问到一些不常被关注的问题,比如: ...

  4. mplayer 全屏问题

    [root@ok home]# gedit ~/.mplayer/config # Write your default config options here! zoom=yes #加上这个参数!全 ...

  5. makefile之override

    override指示符 通常在执行 make 时,如果通过命令行定义了一个变量,那么它将替代在 Makefile中出现的同名变量的定义. 就是说,对于一个在 Makefile 中使用常规方式(使用&q ...

  6. nyoj 760 See LCS again

    See LCS again 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 There are A, B two sequences, the number of ele ...

  7. docker + ubuntun 安装show doc

    基本安装步骤 Ubuntu Docker 安装 Docker 支持以下的 Ubuntu 版本: Ubuntu Precise 12.04 (LTS) Ubuntu Trusty 14.04 (LTS) ...

  8. 16位结构的CPU,8086给出物理地址的方法

    .16位结构的CPU 概括地讲,16位结构(16位机,字长为16位等常见说法,与16位结构的含义相同)描述了一个CPU具有下面几方面结构特性: 1.运算器一次最多可以处理16位的数据结构 2.寄存器的 ...

  9. CodeForces 1A Theatre Square

    A - Theatre Square Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u ...

  10. python学习笔记(8)--爬虫下载占位图片

    说明: 1. 虽然很简单,但总忘,所以还是记下来吧! 2. http://placekitten.com/300/300这个画猫的网站老是打开没有图片,改成了http://placehold.it/3 ...