代码之家  ›  专栏  ›  技术社区  ›  topcat

C/C++开发人员的Eclipse IDE:错误的参数显示错误?

  •  1
  • topcat  · 技术社区  · 6 年前

    在Cclipse IDE中,对于C/C++开发人员Posiy(4.8),我得到了一个错误的参数错误。 map_name.insert(make_pair("string_name", int_name); .

    我使用的是gcc8.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中显示的错误:

    Error

    1 回复  |  直到 6 年前
        1
  •  4
  •   HighCommander4    6 年前

    gcc8附带的标准库实现使用一个名为 __is_constructible ,这是Eclipse CDT的解析器尚不支持的。

    当CDT解析gcc8的标准库代码时,这可能会导致误报错误。

    如果您使用gcc7或更早版本,那么此代码不会出现任何错误。

    This eclipse bug 添加对的支持 __是可构造的吗