vendredi 21 juin 2019

Removing class pointer from member function pointer type

I saw this code snippet in the example on cppreference for std::is_function and I don't understand how it works. Could someone explain to me why U gets deduced as it does in PM_traits?

struct A {
  int fun() const&;
};

template<typename>
struct PM_traits {}; 

template<class T, class U>
struct PM_traits<U T::*> {
  using member_type = U;
};

int main() {
  using T = PM_traits<decltype(&A::fun)>::member_type; // T is int() const&
}

Aucun commentaire:

Enregistrer un commentaire