【发布时间】:2021-02-18 08:37:14
【问题描述】:
我对 C++ 很陌生,所有的红线都让我很烦。我下面的代码 (sn-p) 有效,但它不断突出显示我的 tuple 和 make_tuple 并带有以下警告:分别为 tuple is not a template 和 identifier "make_tuple" is undefined。这是什么意思?
我必须在任何地方定义任何东西吗?
我正在使用 VS Code for Mac。所以,Clang 和我假设是 Xcode。
#include <vector>
//other includes
using namespace std;
//code..
tuple<Gene*, int> find(node* t, bitset<10> bf) {
----- // warning: tuple is not a template <--- HERE
if (something)
if (match>threshold) {
return make_tuple(t->g, match); //<--- AND HERE
---------- // warning: identifier "make_tuple" is undefined
}
else {
return make_tuple(nullptr,0);
}
//code.....
}
配置:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
}
【问题讨论】:
-
红线由您的编辑器/IDE 放在那里。为了帮助您摆脱它们,我们需要知道您使用的是哪个编辑器/IDE。
-
您需要深入研究 IDE 的智能感知配置。您说您的代码有效(所以我假设它可以编译),这意味着构建设置正确。智能感知并不是它看起来的一部分。
-
查看编辑。这够了吗,还是我应该上传更多?