如何在 vscode 中使用 C++20?

Jus*_*hee 6 c++ visual-studio-code

我想在 vscode 中使用 C++20,因为我想在 unordered_set 上使用 .contains,但是当我尝试它时,我得到了但 error C2039: 'contains': is not a member of 'std::unordered_set 我不明白为什么,因为我已经继续使用 c_cpp_properties.json 并指定使用 c++20 但它似乎仍然不起作用,而且我在 vscode 上找不到任何关于更改 C++ 版本的任何内容。

编译器版本: 19.25.28614 for x86

Ted*_*gmo 7

您必须添加 msvc 编译器选项/std:c++latest才能使用unordered_map::contains()成员函数。


小智 6

这是tasks.json针对 Windows 的。只需编辑args并添加"-std=c++23"即可瞧!你的工作完成了!我已从winlibs-x86_64-posix-seh-gcc-12.2.0-llvm-15.0.7-mingw-w64ucrt-10.0.0-r4winlibs离线安装。你也可以做到的。100% 工作。

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:\\mingw64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-std=c++23",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
Run Code Online (Sandbox Code Playgroud)


归档时间:

查看次数:

5019 次

最近记录:

6 年 前