Is it possible to extract a static member type from the class of a local variable? aka something in the lines of
class A {
public:
typedef int constituent_type;
constituent_type a;
A(constituent_type _a) :a(_a) {};
}
int main() {
auto a = A(42);
// ... lots ... of other code; where I have long since forgottten, what the type of a really was
std::max<a::constituent_type>(a, a); //<<<
}
You can do that in C++ 11 or later using decltype
:
decltype(a)::x
Live demo: