我尝试在我使用 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/