I have a function pointer to a static class function Foo::bar()
, and want to get the type of the class (Foo
). Now, I know that I could get the class type if bar
were a member function of Foo
, instead of a static function, with something like the following type trait:
template<class T> struct class_of;
template<class T, class R> struct class_of<R T::*> { using type = T; };
However, this doesn't work for static functions. What I'd like to do is the following:
class_of<Foo::bar>::type
== Foo
It seems to me that the compiler knows all relevant information, so how can this be done?