今天运行程序的时候遇到了下面这个bug

>  B1020.cpp
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2825: '_Iter': 当后面跟“::”时必须为类或命名空间
> e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): 参见对正在编译的类 模板 实例化“std::iterator_traits<_InIt>”的引用
> with
> [
> _InIt=int
> ]
> e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\algorithm(): 参见对正在编译的函数 模板 实例化“void std::_Debug_range<_RanIt>(_InIt,_InIt,std::_Dbfile_t,std::_Dbline_t)”的引用
> with
> [
> _RanIt=int
> , _InIt=int
> ]
1> e:\c++\common\algorithmnote\algorithmnote\b1020.cpp(48): 参见对正在编译的函数 模板 实例化“void std::sort<int,bool(__cdecl *)(mooncake,mooncake)>(_RanIt,_RanIt,_Pr)”的引用
1> with
1> [
1> _RanIt=int
1> , _Pr=bool (__cdecl *)(mooncake,mooncake)
1> ]
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2039: “iterator_category”: 不是“`global namespace'”的成员
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2146: 语法错误: 缺少“;”(在标识符“iterator_category”的前面)
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2602: “std::iterator_traits<_InIt>::iterator_category”不是“std::iterator_traits<_InIt>”基类的成员
> with
> [
> _InIt=int
> ]
> e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility() : 参见“std::iterator_traits<_InIt>::iterator_category”的声明
> with
> [
> _InIt=int
> ]
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2868: “std::iterator_traits<_InIt>::iterator_category”: 非法的 using 声明语法;应输入限定名
> with
> [
> _InIt=int
> ]
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2825: '_Iter': 当后面跟“::”时必须为类或命名空间
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2039: “value_type”: 不是“`global namespace'”的成员
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2146: 语法错误: 缺少“;”(在标识符“value_type”的前面)
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2602: “std::iterator_traits<_InIt>::value_type”不是“std::iterator_traits<_InIt>”基类的成员
> with
> [
> _InIt=int
> ]
> e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility() : 参见“std::iterator_traits<_InIt>::value_type”的声明
> with
> [
> _InIt=int
> ]
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2868: “std::iterator_traits<_InIt>::value_type”: 非法的 using 声明语法;应输入限定名
> with
> [
> _InIt=int
> ]
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2825: '_Iter': 当后面跟“::”时必须为类或命名空间
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2039: “difference_type”: 不是“`global namespace'”的成员
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2146: 语法错误: 缺少“;”(在标识符“difference_type”的前面)
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2602: “std::iterator_traits<_InIt>::difference_type”不是“std::iterator_traits<_InIt>”基类的成员
> with
> [
> _InIt=int
> ]
> e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility() : 参见“std::iterator_traits<_InIt>::difference_type”的声明
> with
> [
> _InIt=int
> ]
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2868: “std::iterator_traits<_InIt>::difference_type”: 非法的 using 声明语法;应输入限定名
> with
> [
> _InIt=int
> ]
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2825: '_Iter': 当后面跟“::”时必须为类或命名空间
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2039: “pointer”: 不是“`global namespace'”的成员
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2146: 语法错误: 缺少“;”(在标识符“pointer”的前面)
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2602: “std::iterator_traits<_InIt>::pointer”不是“std::iterator_traits<_InIt>”基类的成员
> with
> [
> _InIt=int
> ]
> e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility() : 参见“std::iterator_traits<_InIt>::pointer”的声明
> with
> [
> _InIt=int
> ]
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2868: “std::iterator_traits<_InIt>::pointer”: 非法的 using 声明语法;应输入限定名
> with
> [
> _InIt=int
> ]
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2825: '_Iter': 当后面跟“::”时必须为类或命名空间
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2039: “reference”: 不是“`global namespace'”的成员
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2146: 语法错误: 缺少“;”(在标识符“reference”的前面)
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2602: “std::iterator_traits<_InIt>::reference”不是“std::iterator_traits<_InIt>”基类的成员
> with
> [
> _InIt=int
> ]
> e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility() : 参见“std::iterator_traits<_InIt>::reference”的声明
> with
> [
> _InIt=int
> ]
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2868: “std::iterator_traits<_InIt>::reference”: 非法的 using 声明语法;应输入限定名
> with
> [
> _InIt=int
> ]
>e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): error C2665: “std::_Debug_range2”: 个重载中没有一个可以转换所有参数类型
> e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): 可能是“void std::_Debug_range2<_InIt>(_RanIt,_RanIt,std::_Dbfile_t,std::_Dbline_t,std::random_access_iterator_tag)”
> with
> [
> _InIt=int
> , _RanIt=int
> ]
> e:\vs2013\vs2013_rtm_ult_chs\data\vc\include\xutility(): 或 “void std::_Debug_range2<_InIt>(_InIt,_InIt,std::_Dbfile_t,std::_Dbline_t,std::input_iterator_tag)”
> with
> [
> _InIt=int
> ]
> 尝试匹配参数列表“(int, int, std::_Dbfile_t, std::_Dbline_t, int)”时

  首先看到这么多的错误信息就头大,看都不想看,所以我没仔细看这些错误信息,就直接把错误信息的第一行复制到浏览器中去找解决办法,找了挺久时间,确实看到了类似的错误信息,但是跟我也不完全一样,最后看到网上说出现这种情况的原因可能是参数错误或者自定义函数名和库函数名冲突,函数名冲突这个可以排除,因为我确保函数名没有冲突,所以就定位在了参数错误,最后发现 sort 函数的前两个参数必须是迭代器或指针,但是我写了两个整型,所以报错。

  出错的位置

 // 排序
// sort(cakes, cakes + N, cmp); // 正确写法
// sort(0, N, cmp); // 错误写法

  查到的sort函数声明

template <class RandomAccessIterator, class Compare>
void sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp);

  总结:回过头来仔细看看错误信息,发现确实有一点可以看懂的提示,就是我标红的那段,所有提示中出现的函数名中只有这个sort函数名是我见过的,说明其他的都是库函数,说明错误一定是这个sort函数的调用错误,而且貌似标红的错误信息中还提示了参数不匹配的信息,但是由于对冗长错误信息的恐惧感,促使我一开始选择跳过这些错误提示,如果早一点看到这个信息,可以省很多时间,所以告诉自己以后如果再碰到这种又臭又长又看不懂的错误信息时,第一时间不要跳过这些提示,应该从中找到自己认识的部分,很可能错误就出在那里。

error C2825: '_Iter': 当后面跟“::”时必须为类或命名空间 -- 原因可能是参数错误或者自定义函数名和库函数名冲突的更多相关文章

  1. Spring-test使用JUnit时,测试类autowired报错,create bean error

    Spring-test使用JUnit时,测试类里面使用autowired会报错, 报create bean error...... 但是controller里面@autowired可以正常运行的. 在 ...

  2. 完美解决VS2003.Net fatal error LNK1201: 写入程序数据库“.pdb”时出错

    我的开发环境是Win7旗舰64位+VS2003.Net,经常卡pdb错误,文末给出一个完美的解决方案和一个懒人补丁包.问题描述如下:在重新编译的时候,经常报错: fatal error LNK1201 ...

  3. web工程启动时,在一个类中延迟加载Bean,因为该Bean类可能还没被JVM加载

     问题描述: (1)javaWeb项目启动中,还没启动完成,在下面这个类加载另一个Bean类, (2)通过getBean方法获取到该Bean,可以获取到,不为null (3)但是,调用该Bean的方法 ...

  4. "检索COM类工厂中 CLSID为 {00024500-0000-0000-C000-000000000046}的组件时失败,原因是出现以下错误: 80070005" 问题的解决

    一.故障环境 Windows 2008 .net 3.0 二.故障描述 ​ 调用excel组件生成excel文档时页面报错.报错内容一大串,核心是"检索COM类工厂中 CLSID为 {000 ...

  5. 检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80070005

    检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80070005 在CSDN上总是有网友问这个 ...

  6. vs2015 生成项目时,提示执行失败,参数错误

    今天vs2015 生成项目时,提示执行失败,参数错误.查了很多资料未解决 后来,发现只有一个项目出现这个问题,其他项目生成正常.怀疑是该项目解决方案的问题 于是将解决项目中的项目移除,逐一生成引用,解 ...

  7. Objective-C Runtime 运行时之一:类与对象

    Objective-C语言是一门动态语言,它将很多静态语言在编译和链接时期做的事放到了运行时来处理.这种动态语言的优势在于:我们写代码时更具灵活性,如我们可以把消息转发给我们想要的对象,或者随意交换一 ...

  8. 解决Office互操作错误"检索COML类工厂中 CLSID为 {xxx}的组件时失败,原因是出现以下错误: 80070005"

    Excel为例(其他如Word也适用)文件数据导入时报出以下错误: 检索COML类工厂中 CLSID为 {00024500-0000-0000-C000-000000000046}的组件时失败,原因是 ...

  9. C#操作word或excel及水晶报表,检索 COM 类工厂中 CLSID 为 {} 的组件时失败,原因是出现以下错误: 80070005

    解决办法一:<转自http://www.cnblogs.com/Sue_/articles/2123372.html> 具体解决方法如下: 1:在服务器上安装office的Excel软件. ...

随机推荐

  1. C#排序算法的实现---快速排序

    快速排序(Quicksort)是对冒泡排序的一种改进.由C. A. R. Hoare在1962年提出.它的基本思想是:通过一趟排序将要排序的数据分割成独立的两部分,其中一部分的所有数据都比另外一部分的 ...

  2. day5 dict嵌套

    #!/usr/bin/env python # -*- coding:utf-8 -*- dic = { 'name': ['alex', 'wusir', 'taibai'], 'py9': { ' ...

  3. Zjnu Stadium HDU - 3047 带权并查集板子题

    #include<iostream> #include<cstring> #include<cstdio> using namespace std; +; int ...

  4. ansible-yaml语法

    1. 基础语法 - yaml结果通过空格来展示 - 数组使用"- "来表示 //注意:-后边要有一个空格 - 键值对使用": "来表示 //注意::后边要有一个 ...

  5. latex技巧:弧AB

    \usepackage{yhmath} $\wideparen{ABCDEFG}$

  6. layui的跳转链接实现分页low

    layui.use(['laypage', 'layer'], function(){ var laypage = layui.laypage ,layer = layui.layer; laypag ...

  7. 题解 P5712 【【深基3.例4】Apples】

    题目传送门 思路 仔细读题后,我们可以发现,输出可以分成\(2\)种情况,apple加s与apple不加s,所以我们可以使用if/else来实现. 接着,我们读入n. int n; cin>&g ...

  8. 前端页面中:jsp和HTML的区别之处

    JSP和HTML的区别 HTML页面是静态页面,也就是事先由用户写好放在服务器上,固定内容,不会变,由web服务器向客户端发送,平时上网看的网页都是大部分都是基于html语言的. JSP页面是有JSP ...

  9. 题解【AcWing883】高斯消元解线性方程组

    题面 高斯消元模板题. 这里直接讲述一下高斯消元的算法流程: 枚举每一列 \(c\): 找到第 \(c\) 列绝对值最大的一行: 将这一行换到最上面: 将该行的第一个数变成 \(1\): 将下面所有行 ...

  10. Laradock + tp5 + nginx 配置虚拟机域名始终跳转首页/502报错

    laradock默认配置文件如下: 配置运用于本地windows+phpstudy 部署的laravel项目未出现问题,如下: server { listen ; listen [::]:; serv ...