title: Unpacking nested tuples in C++
body: <p><code>std::tie</code> provides a convenient way to unpack the contents of a tuple in C++ into separately defined variables, like the sample below illustrates</p>
  
  <pre><code>int a, b, c, d, e, f;
  
  auto tup1 = std::make_tuple(1, 2, 3);
  std::tie(a, b, c) = tup1;
  </code></pre>
  
  <p>However, if we have a nested tuple like below</p>
  
  <pre><code>auto tup2 = std::make_tuple(1, 2, 3, std::make_tuple(4, 5, 6));
  </code></pre>
  
  <p>attempting to compile the code</p>
  
  <pre><code>std::tie(a, b, c, std::tie(d, e, f)) = tup2;
  </code></pre>
  
  <p>fails with an error</p>
  
  <pre><code>/tmp/tuple.cpp:10: error: invalid initialization of non-const reference of type ‘std::tuple&lt;int&amp;, int&amp;, int&amp;&gt;&amp;’ from an rvalue of type ‘std::tuple&lt;int&amp;, int&amp;, int&amp;&gt;’
    std::tie(a, b, c, std::tie(d, e, f)) = tup2;
                              ^
  </code></pre>
  
  <p>Is there an idiomatic way to unpack a tuple of tuples in C++?</p>