c++ - 面向 C/C++ 开发人员的 Eclipse IDE:错误显示“无效参数”错误?
问题描述
我在 Eclipse IDE for C/C++ Developers Photon (4.8.0) 中收到无效参数错误map_name.insert(make_pair("string_name", int_name);
。
我正在使用 GCC 8.2.0。我正在用 STL 尝试一些简单的东西。
尝试两者insert(make_pair())
或insert(pair<string, int>())
得到相同的 IDE 错误(语义错误)。这是为什么?
代码:
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<string, int> ages;
ages["Mike"] = 21;
ages["Johnny"] = 20;
ages["Vicky"] = 30;
ages["Mike"] = 42;
// ages.insert(make_pair("Peter", 100));
ages.insert(pair < string, int > ("Peter", 100));
for(map<string, int>::iterator it = ages.begin(); it!=ages.end(); it++)
{
cout<< it->first<<": "<< it->second<<endl;
}
return (0);
}
这是 IDE 中显示的错误:
解决方案
GCC 8 附带的标准库实现使用称为 的类型特征内在函数__is_constructible
,Eclipse CDT 的解析器尚不支持。
当使用 CDT 解析 GCC 8 的标准库代码时,这可能会导致误报错误。
如果您使用 GCC 7 或更早版本,则此代码不会出现任何错误。
更新:这个 Eclipse 错误跟踪添加对__is_constructible
CDT 解析器的支持。它最近已被修复,尽管该修复尚未出现在 CDT 版本中。
推荐阅读
- javascript - 如何滚动到 div 内的元素,而不滚动整个页面(没有 JQuery)?
- python - 以根据值具有不同格式的格式化方式打印值?
- html - div圈内的可点击链接
- python - Python:你如何打印出“正确!” 反而?
- reactjs - 初始化状态对象时的空嵌套数组
- c# - 为什么在 C# .Net Core 3 中连接到 MySql 时出现错误
- python - 具有用户定义函数的多列上的 Pandas 数据帧分组聚合
- ruby-on-rails - rspec 上的请求规范是否有正确的文件夹/文件结构?
- django - Django:如何将我的基于函数的视图重新创建为(通用编辑)基于类的视图
- docker - 在 Docker 中使用 Unicorn Flask 配置 Nginx