title: Supporting multiple class interfaces through templating and SFINAE
body: <p>I have a class which is derived off a class provided in a third party library.</p>
  
  <p>Between versions of the third party library, they promoted a member in one of their classes from private to public, but in the move, they deprecated a method for accessing the member. Example:</p>
  
  <pre><code>// Old class
  class A
  {
      public:
          int &amp;GetA() { return a;}
      private:
          int a;
  };
  
  // NewClass
  class A
  {
      public:
          int a;
  };
  </code></pre>
  
  <p>My code uses an instance of <code>A</code>, but I want my code to work with either version, in case someone hasn't updated the library.</p>
  
  <pre><code>class B
  {
     public:
  
     int &amp; ReturnA() { return GetInnards(m_a);}
  
     private:
     A    m_a;
  
    // If m_a has a GetA member function call this:
    template(typename aType)
    int &amp; GetInnards(aType &amp;a) { return a.GetA(); }
  
    // If m_a does not have an GetA() member function, call this:
    template(typename aType)
    int &amp; GetInnards(aType &amp;a) { return a.m_a; }
  };
  </code></pre>
  
  <p>It seems like I should be able to use SFINAE, but I'm missing something.</p>
  
  <p>Also, there is nothing I can test with an <code>#ifdef</code>, so I can't go that route. I need to detect if a method exists, and or if a member is public.</p>