Extract from a member pointer the type of class it points to

How make the following compile correctly with C++20, a.k.a calculate extract<mem_fun>::type? Is it possible?

Error-scenarios like passing non-member function or private function extract<> are not so important for me.

#include <concepts>

struct x
{
    void f()
    {

    }
};

template<auto mem_fun>
struct extract
{
    // using type= ???
};

int main()
{
    using namespace std;
    static_assert(same_as<typename extract<&x::f>::type, x>);
    return 0;
}

Pointers to members all have type T C::*, where T can be either some type or some function type or even some "abominable" function type.

So you just need to specialize on that particular shape:

template<auto mem_fun>
struct extract;

template <typename T, typename C, T C::* v>
struct extract<v> {
    using type = C;
};