title: sorting elements while inserting them into vector not working
body: <p>I'm trying to a vector filled with a randomly generated number, but the problem is that when I run it I get only 2 numbers after sort.</p>
  
  <p>0
  0
  0
  0
  0
  17
  17
  17</p>
  
  <p>this is my code, so can you tell me please what I'm doing wrong</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;random&gt;
  #include &lt;functional&gt;
  
  using namespace std;
  using namespace std::chrono;
  
  class Rand_int {
  public:
  
      Rand_int(int low, int high) :dist{low,high} {
          for (int i = 0; i &lt; 100; i++)
              cout &lt;&lt; "Generated: " &lt;&lt; dist(re) &lt;&lt; endl;
              num = dist(re); }
      int operator()() { return dist(re);}
      int getNum() const
      {
          return num;
      }
      bool operator()(int x) const
      {
          return (num &lt;= x);
      }
  
  private:
      default_random_engine re;
      uniform_int_distribution&lt;&gt; dist;
      int num;
  };
  
  int main()
  {
      int n=10;
      vector&lt;int&gt; v(n);
      Rand_int rnd {0,20};   // make a uniform random number generator
  
      for (int i=0; i&lt;n; i++)
      {
          vector&lt;int&gt;::iterator iter = find_if(v.begin(), v.end(), rnd);
          v.insert(iter, rnd.getNum());
      }
  
      for (vector&lt;int&gt;::const_iterator iter = v.begin(); iter != v.end(); iter++)
          cout &lt;&lt; *iter &lt;&lt; endl;
      return 0;
  }
  </code></pre>