visual studio 2019 c++ - 概念标识符未定义

visual studio 2019 c++ - concept identifier is undefined

我尝试在我使用 visual studio 2019 版本 16.4.1 编写的 cpp 项目中使用概念,但我收到错误消息:"identifier conecpt is undefined"。 据我所知,概念在 visual studio 2019 版 16.3 后得到支持,所以我不明白为什么它仍然对我不起作用。

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

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

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

C++20 概念现在首次在 Visual Studio 2019 版本 16.3 预览版 2 中得到支持。

根据 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模式。

您可以在项目 > 属性 > 配置属性 > C/C++ > 语言 > C++ 语言标准 > 预览 - 最新 C++ 工作草案中的功能 (/std:c++latest)