title: C++ priority queue constructor
body: <p>I found the constructor of priority_queue on <a href="http://www.cplusplus.com/reference/queue/priority_queue/priority_queue/" rel="nofollow noreferrer">http://www.cplusplus.com/reference/queue/priority_queue/priority_queue/</a> is like this :</p>
  
  <pre><code>priority_queue (const Compare&amp; comp, const Container&amp; ctnr);
  </code></pre>
  
  <p>but the example I found is like this:</p>
  
  <pre><code>std::priority_queue&lt;int, std::vector&lt;int&gt;, std::greater&lt;int&gt; &gt; q2;
  </code></pre>
  
  <p>What's the difference between these two constructors?</p>
  
  <p>I have tried both of them on my own, but the first one didn't work, the priority_queue wasn't sorted from small to large. Here is the code: </p>
  
  <pre><code>priority_queue&lt;greater&lt;int&gt;, vector&lt;int&gt;&gt; pq;
  pq.push(4);
  pq.push(2);
  pq.push(1);
  pq.push(3);
  pq.push(5);
  
  for (int i = 0; i &lt; 5; i++) {
      cout &lt;&lt; pq.top() &lt;&lt; endl;
      pq.pop();  
  }
  </code></pre>
  
  <p>The result is still 5, 4, 3, 2, 1</p>