Home > Net >  Why I got syntax error, when trying to use concept?
Why I got syntax error, when trying to use concept?

Time:09-12

I am using Visual Studio 2022, with the latest compiler. I have a problem, when I am trying to create concept definition. I got many syntax error, for example

syntax error: identifier 'has_type_member'

syntax error: missing ';' before '{'

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

I have tried many other basic examples about concepts.

Thanks for your help!

CodePudding user response:

In Visual Studio 2022, ISO C 14 Standard in enabled by default. Concept feature is available since C 20.

To enable ISO C 20 standard for your project, right click on the project name and select Properties, under Configuration Properties -> General -> C Language Standard select ISO C 20 Standard (/stdc 20).

enter image description here

  • Related