title: Template function on struct members
body: <p>Is there a way to code a single template function able to run on different members of a given <code>struct</code> ?</p>
  
  <p>A <strong>wrong</strong> example would look like : </p>
  
  <pre><code>struct Foo
  {
    int a, b;
  }
  
  template &lt;MEMBER x&gt; //which does not exist 
  cout_member(Foo foo)
  {
    cout &lt;&lt; foo.x &lt;&lt; endl;
  }
  
  int main()
  {
    Foo foo; 
    cout_member&lt;a&gt;(foo);
    cout_member&lt;b&gt;(foo);
    return 0;
  }
  </code></pre>
  
  <p>I imagined an answer based on a switch, but I then wondered if this switch would be tested on run-time (what I would like to avoid) or on compile-time ?</p>