Ákos Rittgasszer
Ákos Rittgasszer

Reputation: 13

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

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!

Upvotes: 0

Views: 1434

Answers (1)

DailyLearner
DailyLearner

Reputation: 2354

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

Upvotes: 3

Related Questions