topcat
topcat

Reputation: 189

Eclipse IDE for C/C++ Developers: "invalid arguments" error displayed by mistake?

I'm getting an error of invalid arguments in the Eclipse IDE for C/C++ Developers Photon (4.8.0) at map_name.insert(make_pair("string_name", int_name);.

I am using GCC 8.2.0. I'm trying some simple stuff with STL.

Tried either both insert(make_pair()) or insert(pair<string, int>()) getting same IDE error(Semantic error). Why is that?

Code:

#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);
}

This is the error that is displayed in the IDE:

Error

Upvotes: 1

Views: 1403

Answers (1)

HighCommander4
HighCommander4

Reputation: 52799

The standard library implementation that ships with GCC 8 uses a type trait intrinsic called __is_constructible, which Eclipse CDT's parser does not yet support.

This can result in false positive errors when CDT is made to parse GCC 8's standard library code.

If you use GCC 7 or earlier, you don't get any errors for this code.

UPDATE: This eclipse bug tracks adding support for __is_constructible to CDT's parser. It has recently been fixed, though the fix has not appeared in a CDT release yet.

Upvotes: 4

Related Questions