c++ - Visual Studio 2019 C++ - 未定义概念标识符

标签 c++ visual-studio c++-concepts

我尝试在我使用 Visual Studio 2019 版本 16.4.1 编写的 cpp 项目中使用概念,但我收到错误消息:“标识符 conecpt 未定义”。
据我所知,从 16.3 版开始,visual studio 2019 就支持概念,所以我不明白为什么它仍然对我不起作用。

这是我写的代码,里面有什么愚蠢的语法错误吗?

#include<concepts>
template<typename T>
concept has_type_member = requires { typename T::type; }

如果没有,有没有人遇到过这样的问题并设法克服了它?

最佳答案

Visual Studio 2019 版本 16.3 预览版 2 现在首次支持 C++20 概念。
根据blog :

First, we’re debuting the feature via /std:c++latest mode and once we have all C++20 features implemented across all Visual Studio products (compiler, library, IntelliSense, build system, debugger, etc.), we’ll provide them through a new /std:c++20 mode. IntelliSense support is not currently available and our implementation doesn’t yet include recent changes in the ISO C++ standards meeting in Cologne.


我建议你应该尝试使用 /std:c++latest模式。
您可以在 Project > Properties > Configuration Properties > C/C++ > Language > C++ Language Standard > Preview - Features from the Latest C++ Working Draft (/std:c++latest) 中进行设置

关于c++ - Visual Studio 2019 C++ - 未定义概念标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59379735/

相关文章:

c++ - C2061 错误 : 'identifier' , 但我包含了 header ?

c++ - 在 C++ 中创建多个进程并与管道通信

visual-studio - 使用 Crystal Reports 组编辑器时 Visual Studio 崩溃

c++ - 智能指针的概念

c++ - 何时在 C++20 中使用约束实现模板

c++ - GNU 内置函数 `__builtin_unreachable ` 如何在此代码片段中工作?

c++ - C++中的正则表达式问题

c++ - Visual Studio 的 "preprocess current file"插件? (C++)

visual-studio - 无法在 Visual Studio 中同步我的项目

c++ - 具有嵌套类型的类的概念