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软件. ...
随机推荐
- java 上传文件到七牛云中
import com.alibaba.fastjson.JSONObject;import com.qiniu.common.QiniuException;import com.qiniu.commo ...
- java设计模式学习笔记--单一职责原则
单一职责原则注意事项和细节 1.降低类的复杂度,一个类只负责一项职责 2.提高可读性,可维护性 3.降低变更引起的风险 4.通常情况下,我们应当遵守单一职责原则,只有逻辑足够简单,才可以在代码级违反单 ...
- Redis的各个数据的类型基本命令
什么是Redis: 概念: Redis (REmote DIctionary Server) 是用 C 语言开发的一个开源的高性能键值对(key-value)数据库. 特征:1. 数据间没有必然的关联 ...
- JavaSE学习笔记(3)---面向对象三大特性
JavaSE学习笔记(3)---面向对象三大特性 面向对象的三大特征:继承.封装.多态 1.封装 面向对象编程语言是对客观世界的模拟,客观世界里成员变量都是隐藏在对象内部的,外界无法直接操作和修改.然 ...
- Redis 数据类型及操作
前言 作为Key-value型数据库,Redis也提供了键(Key)和键值(Value)的映射关系.但是,除了常规的数值或字符串,Redis的键值还可以是以下形式之一: Lists (可重复列表) S ...
- oracle备份与还原数据
一.表数据备份与还原 creat table 备份表 select * from 原表 where insert into 原表 select * from 备份表 二.利用备份 ...
- UVA1401 (字典树加简单dp)
#pragma GCC optimize(2) #include <bits/stdc++.h> #define ll long long using namespace std; ; ; ...
- 2020牛客寒假算法基础集训营4-F树上博弈
链接:https://ac.nowcoder.com/acm/contest/3005/F来源:牛客网 题目描述 现有一个 n 个点,n-1条边组成的树,其中 1 号点为根节点. 牛牛和牛妹在树上玩游 ...
- PAT (Advanced Level) Practice 1120 Friend Numbers (20 分) (set)
Two integers are called "friend numbers" if they share the same sum of their digits, and t ...
- C语言 Char* 和Char 用法
分类专栏: C语言 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/imxlw00/ar ...