title: Every combination of X numbers possible if we select one value from each of Y vectors
body: <p>If there is a formal name for this problem (or this is a duplicate and I haven't found the right question to look at) then pointing out what I should actually be searching for would also be appreciated! However, I haven't been able to find any discussion or approaches to this specific problem.</p>
  
  <p>I'm trying to keep the question as simple as possible, if more details would help just let me know.</p>
  
  <p>Say we have four random length vectors of int:</p>
  
  <pre><code>std::vector&lt;int&gt; v1 {1, 7, 5, 2};
  std::vector&lt;int&gt; v2 {4, 2, 1};
  std::vector&lt;int&gt; v3 {1, 9, 4, 6, 4, 1, 2};
  std::vector&lt;int&gt; v4 {9, 4};
  </code></pre>
  
  <p>Out of these four vectors, I need to generate every possible combination  where we select only one int from each source vector (v1 - v4) at a time. The result should be that we generate every possible N length number out of the source vectors where N = the number of source vectors (4 in this case).</p>
  
  <p>A few of the possible combinations are very easy to generate, for example selecting just the first number out of each source vector:</p>
  
  <pre><code>1 4 1 9
  </code></pre>
  
  <p>Selecting the last number of each source vector:</p>
  
  <pre><code>2 1 2 4
  </code></pre>
  
  <p>Where I'm stuck is generating every single combination possible. I need every possible N length number that can be created by combining one int from each of the 4 source vectors.</p>
  
  <p>Thank you!</p>