c++concept

Visual Studio Community 2022 Identifier concept is undefined


I'm a beginner with C++ and VisualStudio Community 2022(v17.4.3) and started to familiarize myself with concept feature but got into trouble with build. I'm trying to run this code but build is failed with message Identifier 'concept' is undefined

#include <iostream>
#include <concepts>

template<typename T>
concept C1 = sizeof(T) != sizeof(int);

int main()
{
    std::cout << __cplusplus << "Hello World!\n";
}

If I remove the concept and run it, this is the output(See update below): enter image description here

I also found these topics, but neither helped me.

Visual Studio for C++ - identifier "concept" is undefined

visual studio 2019 c++ - concept identifier is undefined

Undefined identifier "concept" in Visual Studio 2022

Visual studio 2019 c++ support of concepts - compiles successfully with error: Why?

Looks like Intellisence is not available for me because it is community version.(so this would be not the root cause). Project Language configurations also look right. See the screenshot below. enter image description here

I would be really appreciated for any help with this.

Update(one inaccuracy) If I remove concept code

#include <iostream>
#include <concepts>

//template<typename T>
//concept C1 = sizeof(T) != sizeof(int);

int main()
{
    std::cout << __cplusplus << "Hello World!\n";
    std::cout << _MSC_VER << "Hello World!\n";
}

I'm getting this enter image description here


Solution

  • I've managed to solve this issue. Thank you all for the ideas. The solution below.

    I am running the project with Configuration: Debug and Platform: x64

    But when I opened Right Click on Project -> Properties , etc. I didn't notice that it was opened with different configuration and platform. So in my case I just changed Configuration and Platform to the ones I'm working on, changed C++ Language Standardto the latest, clicked Ok and it started to work. enter image description here