c++ stl priority_queue with a custom comparator as function parameter <p>I want to use priority_queue and pass it to a function:</p> <pre><code>// compare points according their distance to some target point struct MyComparator { Point target; MyComparator(Point t) : target(t) {} bool operator() (const Point&amp; p1, const Point&amp; p2) { return distance(target, p1) &lt; distance(target, p2); } }; typedef priority_queue&lt;Point, vector&lt;Point&gt;, MyComparator&gt; myque; void myfunc(const Point&amp; target, myque&amp; que) { ... } // call myfunc Point target = ...; myque queue(MyComparator(target)); myfunc(target, queue); // error : no matching function for call to ‘myfunc(const Point&amp;, myque (&amp;)(MyComparator))’ </code></pre> <p>How can I resolve this error?</p> <p>Thanks. </p>