IntelliSense in VSCode (on MacOS) does not use c++20 std option

Viewed 39

MacOS 12.5.1, vscode: 1.71.0, IntelliSense: v1.12.4

Here is (from what I understand) the relevant portion of c_cpp_properties.json

            "cStandard": "c17",
            "cppStandard": "c++20",

Here is some simple code that shows this issue:

#include <stdio.h>

#include <unistd.h>
#include <unordered_map>

#include <iostream>
using namespace std;

class test {
  public:
    test(){};

    enum my_enum
    {
        one = 0,
        two = 1,
        three = 2
    };

    const char *my_enum_to_str(my_enum input);
};

const char *test::my_enum_to_str(my_enum input)
{
    const std::unordered_map<my_enum, const char *> map = //
        {{my_enum::one, "One"}, {my_enum::two, "Two"}, {my_enum::three, "Three"}};

    auto item = map.find(input);
    if (item == map.end()) {
        return "type not found";
    }

    return item->second;
}

int main()
{
    test instance;

    printf("%s\n", instance.my_enum_to_str(test::my_enum::one));

    return 0;
}

And the IntelliSense errors: IntelliSense output

name followed by '::' must be a class or namespace name

The code compiles and runs with in MacOS

clang++ -std=c++20 test_class.cc

and Linux

g++ test_class.cc 
0 Answers
Related