title: How to detect whether there is a specific member variable in class?
body: <p>For creating algorithm template function I need to know whether x or X (and y or Y) in class that is template argument. It may by useful when using my function for MFC CPoint class or GDI+ PointF class or some others. All of them use different x in them. My solution could be reduces to the following code:</p>
  
  <pre><code>
  template&lt;int&gt; struct TT {typedef int type;};
  template&lt;class P&gt; bool Check_x(P p, typename TT&lt;sizeof(&P::x)&gt;::type b = 0) { return true; }
  template&lt;class P&gt; bool Check_x(P p, typename TT&lt;sizeof(&P::X)&gt;::type b = 0) { return false; }
  
  struct P1 {int x; };
  struct P2 {float X; };
  // it also could be struct P3 {unknown_type X; };
  
  int main()
  {
      P1 p1 = {1};
      P2 p2 = {1};
  
      Check_x(p1); // must return true
      Check_x(p2); // must return false
  
      return 0;
  }
  </code></pre>
  
  <p>But it does not compile in Visual Studio, while compiling in the GNU C++. With Visual Studio I could use the following template:</p>
  
  <pre><code>
  template&lt;class P&gt; bool Check_x(P p, typename TT&lt;&P::x==&P::x&gt;::type b = 0) { return true; }
  template&lt;class P&gt; bool Check_x(P p, typename TT&lt;&P::X==&P::X&gt;::type b = 0) { return false; }
  </code></pre>
  
  <p>But it does not compile in GNU C++. Is there universal solution?</p>
  
  <p>UPD: Structures P1 and P2 here are only for example. There are could be any classes with unknown members.</p>
  
  <p>P.S. Please, do not post C++11 solutions here because they are obvious and not relevant to the question.</p>