This question is based on this post.
Goal: I would like to know if a class has the member variable x. I would like to receive true
x
true
The following seems to work. Please tell me if it needs improvement. Live example.
class Haser { public: template static constexpr bool HasX = false; template static constexpr bool HasX = true; }; struct A { private: int x; friend Haser; };
Haser::HasX is true.
Haser::HasX