title: Generating all size k subsets of {0, 1, 2, ... n-1}
body: <p>I want to generate all cardinality <code>k</code> subsets of <code>{0, 1, 2, ..., n-1}</code> in C++. In Haskell, I would do:</p>
  
  <pre><code>sets 0 n = [[]]
  sets k n = [i:s | i &lt;- [0..n-1], s &lt;- sets (k-1) i]
  </code></pre>
  
  <p>Or in Python:</p>
  
  <pre><code>def sets(k, n):
      if k == 0:
          return [()]
      return ((i,)+s for i in range(n) for s in sets(k-1, i))
  </code></pre>
  
  <p>So, for example, (line breaks added for clarity)</p>
  
  <pre><code>ghci&gt; sets 2 8
  [[1,0],
   [2,0],[2,1],
   [3,0],[3,1],[3,2],
   [4,0],[4,1],[4,2],[4,3],
   [5,0],[5,1],[5,2],[5,3],[5,4],
   [6,0],[6,1],[6,2],[6,3],[6,4],[6,5],
   [7,0],[7,1],[7,2],[7,3],[7,4],[7,5],[7,6]]
  </code></pre>
  
  <p>What would be the "C++ way" of doing this? Note that I'm not asking <em>how</em> to solve the problem. I'm asking about what data types would be considered "normal" by C++ programmers.</p>
  
  <p><sup>(For reference, I'm vaguely familiar with C++ and somewhat familiar with C.)</sup></p>