title: Permutations &/ Combinations using c++
body: <p>I need a different version of permutations for my code. I could able to achieve what I want but it is not generic enough. my algorithm keeps going bigger along with my requirements. But that should not be.</p>
  
  <p>This is not a home work for any one, I need it for one my critical projects, wondering if any pre-defined algorithms available from boost or any other.</p>
  
  <p>Below is the standard version of next_permutation using c++.</p>
  
  <pre><code>// next_permutation example
  #include &lt;iostream&gt;     // std::cout
  #include &lt;algorithm&gt;    // std::next_permutation
  
  int main () 
  {
    int myints[] = {1,2,3};
    do 
    {
      std::cout &lt;&lt; myints[0] &lt;&lt; ' ' &lt;&lt; myints[1] &lt;&lt; ' ' &lt;&lt; myints[2] &lt;&lt; '\n';
    } while ( std::next_permutation(myints,myints+3) );
  
  
    return 0;
  }
  </code></pre>
  
  <p>That gives below output :</p>
  
  <pre><code>1 2 3
  1 3 2
  2 1 3
  2 3 1
  3 1 2
  3 2 1
  </code></pre>
  
  <p>But my requirement is :- Let's say I have 1 to 9 numbers : 
  1,2,3,4,5,6,7,8,9</p>
  
  <p>And I need a variable length of permutations and in only ASCENDING order and with out DUPLICATES.</p>
  
  <p>Let's say i need 3 digit length of permutations then i need output as below.</p>
  
  <pre><code>123
  124
  125
  .
  .
  .
  128
  129
  134   // After 129 next one should be exactly 134
  135      // ascending order mandatory
  136
  .
  .
  .
  148
  149
  156   // exactly 156 after 149, ascending order mandatory
  .
  .
  .
  489   // exactly 567 after 489, because after 3rd digit 9, 2nd digit
  567   // will be increased to 49? , so there is no possibility for
  .     // 3rd digit, so first digit gets incremented to 5 then 6 then
  .     // 7, in ascending order.
  .     
  .
  .
  789   // and this should be the last set I need.
  </code></pre>
  
  <p>My list may contain upto couple of hundred's of numbers and variable length can be 1 to up to Size of the list.</p>
  
  <p>My own algorithm is working for specific variable length, and a specific size, when they both changes, i need to write huge code. so, looking for a generic one.</p>
  
  <p>I am not even sure if this is called as Permutations or there is a different name available for this kind of math/logic.</p>
  
  <p>Thanks in advance.
  musk's</p>