Are concepts able to check private non-static data members?

Viewed 96

I made a concept that checks the type of a data member:

#include <concepts>
#include <iostream>

template < typename DataType >
struct StaticA
{
private:
    static DataType value;
};

template < typename DataType >
struct NonStaticA
{
private:
    DataType value;
};

template < typename DataType >
struct B
{
    DataType value;
};

template < typename Class >
concept Concept = std::same_as < decltype(Class::value), int >;

int main()
{
    std::cout << Concept < StaticA < int > > << "\n"; // Prints 0
    std::cout << Concept < NonStaticA < int > > << "\n"; // Prints 0 or 1, depending on the compiler.
    std::cout << Concept < B < int > > << "\n"; // Prints 1

    return 0;
}

In this case, the second print should also be 0 on MSVC, just like it happens on gcc, right?

I believe that's the case, because of this answer: C++ concept with friend-like access

You may check the aforementioned code here: https://godbolt.org/z/9afcEes7x

Thanks for your attention!

1 Answers
Related