Search code examples
c++11type-traits

How to use C++11 std::is_member_object_pointer in type_traits?


struct A { int x; };

int main() {
    int A::* pt = &A::x;
    return 0;
}

what does int A::* mean exactly? I have never seen C++ syntax like this.


Solution

  • Just like other traits, you specify the template argument and use the value member.

    std::is_member_object_pointer<decltype(pa) >::value
    

    what does int A::* mean exactly?

    That is a type declaration of a member object pointer to an int member of the class A.