title: What is the use of decltype in this code ?
body: <p>I have a written a small piece of code which throws a lot of error, If I dont't use the <code>decltype</code> keyword while with the <code>decltype</code> keyword it compiles fine : -</p>
  
  <pre><code>   std::function&lt;bool(int,int)&gt; f2 = [dist](int n1,int n2) {if(dist[n1] &lt; dist[n2]) return false ; return true ; } ; 
          priority_queue&lt;int,vector&lt;int&gt;,decltype(f2)&gt;  pq(f2)  ; 
  </code></pre>
  
  <p>Here, I wanted to declare a <code>priority_queue</code> with my own custom comparison function, so I decided to use <code>std::function</code> and lambdas.<br>
  Also, <code>dist</code> is a <code>std::vector&lt;int&gt;</code> </p>
  
  <p>But strangely , the code gives error if I replace <code>decltype(f2)</code> with just <code>f2</code>.   </p>
  
  <p>Why is is so ? </p>