error C2825: '_Iter': 当后面跟“::”时必须为类或命名空间 -- 原因可能是参数错误或者自定义函数名和库函数名冲突
今天运行程序的时候遇到了下面这个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': 当后面跟“::”时必须为类或命名空间 -- 原因可能是参数错误或者自定义函数名和库函数名冲突的更多相关文章
- Spring-test使用JUnit时,测试类autowired报错,create bean error
Spring-test使用JUnit时,测试类里面使用autowired会报错, 报create bean error...... 但是controller里面@autowired可以正常运行的. 在 ...
- 完美解决VS2003.Net fatal error LNK1201: 写入程序数据库“.pdb”时出错
我的开发环境是Win7旗舰64位+VS2003.Net,经常卡pdb错误,文末给出一个完美的解决方案和一个懒人补丁包.问题描述如下:在重新编译的时候,经常报错: fatal error LNK1201 ...
- web工程启动时,在一个类中延迟加载Bean,因为该Bean类可能还没被JVM加载
问题描述: (1)javaWeb项目启动中,还没启动完成,在下面这个类加载另一个Bean类, (2)通过getBean方法获取到该Bean,可以获取到,不为null (3)但是,调用该Bean的方法 ...
- "检索COM类工厂中 CLSID为 {00024500-0000-0000-C000-000000000046}的组件时失败,原因是出现以下错误: 80070005" 问题的解决
一.故障环境 Windows 2008 .net 3.0 二.故障描述 调用excel组件生成excel文档时页面报错.报错内容一大串,核心是"检索COM类工厂中 CLSID为 {000 ...
- 检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80070005
检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80070005 在CSDN上总是有网友问这个 ...
- vs2015 生成项目时,提示执行失败,参数错误
今天vs2015 生成项目时,提示执行失败,参数错误.查了很多资料未解决 后来,发现只有一个项目出现这个问题,其他项目生成正常.怀疑是该项目解决方案的问题 于是将解决项目中的项目移除,逐一生成引用,解 ...
- Objective-C Runtime 运行时之一:类与对象
Objective-C语言是一门动态语言,它将很多静态语言在编译和链接时期做的事放到了运行时来处理.这种动态语言的优势在于:我们写代码时更具灵活性,如我们可以把消息转发给我们想要的对象,或者随意交换一 ...
- 解决Office互操作错误"检索COML类工厂中 CLSID为 {xxx}的组件时失败,原因是出现以下错误: 80070005"
Excel为例(其他如Word也适用)文件数据导入时报出以下错误: 检索COML类工厂中 CLSID为 {00024500-0000-0000-C000-000000000046}的组件时失败,原因是 ...
- C#操作word或excel及水晶报表,检索 COM 类工厂中 CLSID 为 {} 的组件时失败,原因是出现以下错误: 80070005
解决办法一:<转自http://www.cnblogs.com/Sue_/articles/2123372.html> 具体解决方法如下: 1:在服务器上安装office的Excel软件. ...
随机推荐
- OpenCV学习记录(C++版本)
HighGUI组件 图像的载入:imread()函数 Mat imread(const string& filename, int flag = 1)其中flag=1代表读入RGB彩色图像,- ...
- 安装ubuntu到移动硬盘(UEFI+GPT),实现在别的电脑也可以使用(详细教程)
前置说明:博主小白,第一次安装ubuntu,参考了网上很多人的教程,发博记录一下自己的安装过程.由于有些地方博主理解较浅或者因为机器硬件等各方面原因,本教程适用有限,仅供参考. 1.准备工作 win系 ...
- AE工程渲染的时间缓慢,两种方法减少对AE工程渲染的时间!
AE工程渲染的时间缓慢,两种方法减少对AE工程渲染的时间!3秒的片头,渲染时间竟然要花1个多小时,很多新手都产生过这样的疑问?是哪里不对吗?如何才能减少渲染视频的时间?且听我一一道来.主要原因是:工程 ...
- [Python] 前程无忧招聘网爬取软件工程职位 网络爬虫 https://www.51job.com
首先进入该网站的https://www.51job.com/robots.txt页面 给出提示: 找不到该页 File not found 您要查看的页已删除,或已改名,或暂时不可用. 请尝试以下操作 ...
- Wireshark下载地址
官方下载地址: https://www.wireshark.org/download.html
- fake_useragent-Html-请求头
fake_useragent HTML请求头 from fake_useragent import UserAgent ua = UserAgent() # 得到ua对象 print(ua.ie) # ...
- javascript当中onload用法
7)onload onload就是等页面加载完后才执行. 例 3.7.1 <HEAD> <meta http-equiv="content-type" conte ...
- 剑指offer-面试题28-对称的二叉树-二叉树递归
/* 题目: 判断给定的二叉树是否对称. */ /* 思路: 1.递归法. 2.基础条件:两棵树均为空为true:一棵树为空,一棵树不为空,为false:两棵树的根节点值不同,为false. 3.其它 ...
- 剑指offer-面试题21-调整数组顺序使奇数位于偶数前面-双指针
/* 题目: 调整数组顺序使奇数位于偶数前面. */ /* 思路: 双指针: 一个指针last用于遍历,当为奇数时+1, 当为偶数时,交换last和pre指向的值,向前移动pre指针. */ #inc ...
- json转义处理
php把参数转成json字符串,中文会变成unicode,有部分会自动转义(添加反斜杠\) json_encode() #中文不转义对应的数字 256) json_encode($data,JSON_ ...