1
struct A
{
    template<typename T>
    concept IsGood = sizeof(T) == sizeof(int); 
    // error: concept declarations may only appear in global or namespace scope

    void f(IsGood auto n)
    {}
};

int main()
{
    A{}.f(8);
}

See online demo: https://godbolt.org/z/fv5fePdbf

Now that we can define a class nested in another class, then,

Why does C++20 not allow a concept declared nested in a class?

xmllmx
  • 39,765
  • 26
  • 162
  • 323
  • Similar to `using` declaration, you can have `concept` which may depend upon the template parameter.. – Const Oct 21 '21 at 07:22

0 Answers0