title: Custom Comparator for Priority Queue of a pair<int, pair<int, int> >
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;queue&gt;
  using namespace std;
  
  template&lt; typename FirstType, typename SecondType &gt;
  struct PairComparator {
    bool operator()( const pair&lt;FirstType, SecondType&gt;&amp; p1, const pair&lt;FirstType, SecondType&gt;&amp; p2 ) const 
      {  if( p1.first &lt; p2.first ) return true;
          if( p2.first &lt; p1.first ) return false;
          //return p1.second &lt; p2.second;
      }
  };
  
  priority_queue&lt;pair&lt;int, pair&lt;int, int&gt; &gt; &gt; q;
  
  int main() {
      q.push(make_pair(1, make_pair(2,3)));
      pair&lt;int, pair&lt;int, int&gt; &gt; a = q.top;
      return 0;
  }
  </code></pre>
  
  <p>This gives me the error</p>
  
  <pre><code>pqpair.cpp:18: error: conversion from ‘&lt;unresolved overloaded function type&gt;’ 
  to non-scalar type ‘std::pair&lt;int, std::pair&lt;int, int&gt; &gt;’ requested
  </code></pre>
  
  <p>I found the <code>PairComparator</code> code from the cplusplus.com forums</p>