visual studio 2019 c++ - concept identifier is undefined

元气小坏坏 提交于 2021-01-27 12:10:35

问题


I have tried to use concepts in my cpp project which I write using visual studio 2019 version 16.4.1 but I get and error message: "identifier conecpt is undefined". As far as I know concepts have support in visual studio 2019 since version 16.3 so I cant understand why it still doesn't work for me.

Here is the code I have written, Is there any foolish syntax error in it?

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

If not has anyone have had such a problem and have managed to overcome it?


回答1:


C++20 Concepts are now supported for the first time in Visual Studio 2019 version 16.3 Preview 2.

According to the 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.

I suggest you should try to use /std:c++latest mode.

You can set this at Project > Properties > Configuration Properties > C/C++ > Language > C++ Language Standard > Preview - Features from the Latest C++ Working Draft (/std:c++latest)



来源:https://stackoverflow.com/questions/59379735/visual-studio-2019-c-concept-identifier-is-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!