title: c++ template function with predicate support
body: <p>I want to implement a priority queue using template.I tried but i am getting some error , i want to pass custom predicate support for less function.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  template &lt;typename T, std::size_t N, typename lessFunction&gt;
  class MyClass
  {
      typedef std::size_t     size_type;
  public:
      void push( const T&amp; t) {
          //
          size_type index ;//(some value .. say 5)
          //...//
          if(lessFunction(m_buffer[index], t))
          {
              /// do something
          }
      }
  
  private:
      T m_buffer[N];
  };
  
  struct myCompare
  {
      bool operator() (int&amp; x, const int&amp; y) {
          return abs(x) &lt; abs(y);
      }
  };
  
  int main()
  {
      MyClass&lt;int , 8, myCompare&gt; obj;
      obj.push(1);
      return 0;
  }
  </code></pre>
  
  <p>I am getting this error.</p>
  
  <pre><code>/home/sanju/code/circular-buffer/main.cpp:17: error: no matching function for call to 'myCompare::myCompare(int&amp;, const int&amp;)'
           if(lessFunction(m_buffer[index], t))
  </code></pre>
  
  <p>Please correct me. And i have one more question
  how can this template use a functor as well as function as lessFunction ?</p>