title: Perfect forwarding a member of object
body: <p>Suppose I have two <code>struct</code>s:</p>
  
  <pre><code>struct X {};
  struct Y { X x; }
  </code></pre>
  
  <p>I have functions:</p>
  
  <pre><code>void f(X&amp;);
  void f(X&amp;&amp;);
  </code></pre>
  
  <p>How do I write a function <code>g()</code> that takes <code>Y&amp;</code> or <code>Y&amp;&amp;</code> but perfect forwarding <code>X&amp;</code> or <code>X&amp;&amp;</code> to <code>f()</code>, respectively:</p>
  
  <pre><code>template &lt;typename T&gt;
  void g(T&amp;&amp; t) {
    if (is_lvalue_reference&lt;T&gt;::value) {
      f(t.x);
    } else {
      f(move(t.x));
    }
  }
  </code></pre>
  
  <p>The above code illustrate my intention but is not very scalable as the number of parameters grows.  Is there a way make it work for perfect forwarding and make it scalable?</p>