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软件. ...
随机推荐
- ubuntu 安装mysql数据库
apt方式安装 官网参考: https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/ 执行命令: sudo wget https://dev.m ...
- Java Web笔记(2)
学习笔记,狂神说java,链接:https://www.bilibili.com/video/av68833391 5.Maven 我为什么要学习这个技术? 在Javaweb开发中,需要使用大量的ja ...
- Spring Mvc Http 400 Bad Request问题排查
如果遇到了Spring MVC报错400,而且没有返回任何信息的情况下该如何排查问题? 问题描述 一直都没毛病的接口,今天测试的时候突然报错400 Bad Request,而且Response没有返回 ...
- sqlserver2014部署安装
百度云网址链接: https://pan.baidu.com/s/1BwgdnESI8Fqlos9EIOLv1A 提取码: wsy5 1.解压ISO镜像文件,点击setup安装程序 2.进入安装界面 ...
- 【转】为什么使用length获取Java数组的长度
记得vamcily 曾问我:“为什么获取数组的长度用.length(成员变量的形式),而获取String的长度用.length()(成员方法的形式)?” 我当时一听,觉得问得很有道理.做同样一件事情, ...
- 【笔记】机器学习 - 李宏毅 - 11 - Keras Demo2 & Fizz Buzz
1. Keras Demo2 前节的Keras Demo代码: import numpy as np from keras.models import Sequential from keras.la ...
- ARM微处理器中支持字节、半字、字三种数据类型,地址的低两位为0是啥意思?
问题: ARM微处理器中支持字节.半字.字三种数据类型,其中,字需要4字节对齐(地址的低两位为0).半字需要2字节对齐(地址的最低位为0).我想问的是括号中的内容是什么意思呢?请牛人帮忙解释一下!谢谢 ...
- Redis的各个数据的类型基本命令
什么是Redis: 概念: Redis (REmote DIctionary Server) 是用 C 语言开发的一个开源的高性能键值对(key-value)数据库. 特征:1. 数据间没有必然的关联 ...
- 【UWP】在 UWP 中使用 Exceptionless 进行遥测
2020年1月17日更新: nightly build 版本已发布 https://www.myget.org/feed/exceptionless/package/nuget/Exceptionle ...
- HDU 6417
题意 英文 做法 \(S_{a,b}\)为\(a\)与\(b\)中素数次幂奇偶性不同的集合,容易得出\[d_{a,b}=\left\{\begin{aligned}1 &&|S_{a, ...