title: C++ Variadic Template to Evaluate Pointer to Member
body: <p>I would like to create a variadic template that evaluates nested pointer to members.  I have tried the following:</p>
  
  <pre><code>template&lt;typename T, typename U, typename... V&gt;
  auto getField(T &amp;input, U (T::*field), V... args)
      -&gt; decltype(getField(input.*field, &amp;args...))
  {
      getField(input.*field, &amp;args...);
  }
  
  template&lt;typename T, typename U&gt;
  U getField(T &amp;input, U (T::*field))
  {
      return input.*field;
  }
  
  struct inner {
      int val;
  };
  
  struct outer {
      inner in;
  };
  
  void main() {
      outer p{{5}};
      cout &lt;&lt; getField(p, &amp;outer::in, &amp;inner::val) &lt;&lt; endl;
  }
  </code></pre>
  
  <p>When I compile the above in VS, I get the following error messages:</p>
  
  <blockquote>
    <p>error C2672: 'getField': no matching overloaded function found<br/>
    error C2893: Failed to specialize function template 'unknown-type getField(T &amp;, U T::* ,V...)'<br/>
    note: With the following template arguments:<br/>
    note: 'T=outer'<br/>
    note: 'U=outer::inner'<br/>
    note: 'V={int outer::inner::* }'</p>
  </blockquote>
  
  <p>How can I fix the above variadic template to compile, and return <code>p.in.val</code>?  Note that my compiler doesn't support auto template parameters.</p>