title: GCC Compilation error: no match for ‘operator<’
body: <p>G++ has been kind of trolling me with this huge error report. But I'm totally unable to extract any information out of it. It would be great if you could help me.</p>
  
  <p>As far as I got the error should be connected to operator <code>&lt;</code>, which is defined in class Calendar.cpp. But whatever I try to do, I'm just getting more and more error.</p>
  
  <pre><code>In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h: In instantiation of ‘bool std::less&lt;_Tp&gt;::operator()(const _Tp&amp;, const _Tp&amp;) const [with _Tp = activationRecord]’:
  /usr/include/c++/4.8.2/bits/stl_heap.h:313:40:   required from ‘void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator&lt;activationRecord*, std::vector&lt;activationRecord, std::allocator&lt;activationRecord&gt; &gt; &gt;; _Distance = long int; _Tp = activationRecord; _Compare = std::less&lt;activationRecord&gt;]’
  /usr/include/c++/4.8.2/bits/stl_heap.h:448:15:   required from ‘void std::make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator&lt;activationRecord*, std::vector&lt;activationRecord, std::allocator&lt;activationRecord&gt; &gt; &gt;; _Compare = std::less&lt;activationRecord&gt;]’
  /usr/include/c++/4.8.2/bits/stl_queue.h:399:48:   required from ‘std::priority_queue&lt;_Tp, _Sequence, _Compare&gt;::priority_queue(const _Compare&amp;, const _Sequence&amp;) [with _Tp = activationRecord; _Sequence = std::vector&lt;activationRecord, std::allocator&lt;activationRecord&gt; &gt;; _Compare = std::less&lt;activationRecord&gt;]’
  Calendar.h:15:7:   required from here
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: error: no match for ‘operator&lt;’ (operand types are ‘const activationRecord’ and ‘const activationRecord’)
         { return __x &lt; __y; }
                      ^
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note: candidates are:
  In file included from /usr/include/c++/4.8.2/bits/stl_algobase.h:64:0,
                   from /usr/include/c++/4.8.2/bits/char_traits.h:39,
                   from /usr/include/c++/4.8.2/ios:40,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_pair.h:220:5: note: template&lt;class _T1, class _T2&gt; bool std::operator&lt;(const std::pair&lt;_T1, _T2&gt;&amp;, const std::pair&lt;_T1, _T2&gt;&amp;)
       operator&lt;(const pair&lt;_T1, _T2&gt;&amp; __x, const pair&lt;_T1, _T2&gt;&amp; __y)
       ^
  /usr/include/c++/4.8.2/bits/stl_pair.h:220:5: note:   template argument deduction/substitution failed:
  In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note:   ‘const activationRecord’ is not derived from ‘const std::pair&lt;_T1, _T2&gt;’
         { return __x &lt; __y; }
                      ^
  In file included from /usr/include/c++/4.8.2/bits/stl_algobase.h:67:0,
                   from /usr/include/c++/4.8.2/bits/char_traits.h:39,
                   from /usr/include/c++/4.8.2/ios:40,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_iterator.h:297:5: note: template&lt;class _Iterator&gt; bool std::operator&lt;(const std::reverse_iterator&lt;_Iterator&gt;&amp;, const std::reverse_iterator&lt;_Iterator&gt;&amp;)
       operator&lt;(const reverse_iterator&lt;_Iterator&gt;&amp; __x,
       ^
  /usr/include/c++/4.8.2/bits/stl_iterator.h:297:5: note:   template argument deduction/substitution failed:
  In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note:   ‘const activationRecord’ is not derived from ‘const std::reverse_iterator&lt;_Iterator&gt;’
         { return __x &lt; __y; }
                      ^
  In file included from /usr/include/c++/4.8.2/bits/stl_algobase.h:67:0,
                   from /usr/include/c++/4.8.2/bits/char_traits.h:39,
                   from /usr/include/c++/4.8.2/ios:40,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_iterator.h:347:5: note: template&lt;class _IteratorL, class _IteratorR&gt; bool std::operator&lt;(const std::reverse_iterator&lt;_Iterator&gt;&amp;, const std::reverse_iterator&lt;_IteratorR&gt;&amp;)
       operator&lt;(const reverse_iterator&lt;_IteratorL&gt;&amp; __x,
       ^
  /usr/include/c++/4.8.2/bits/stl_iterator.h:347:5: note:   template argument deduction/substitution failed:
  In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note:   ‘const activationRecord’ is not derived from ‘const std::reverse_iterator&lt;_Iterator&gt;’
         { return __x &lt; __y; }
                      ^
  In file included from /usr/include/c++/4.8.2/string:52:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/basic_string.h:2569:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; bool std::operator&lt;(const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;, const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;)
       operator&lt;(const basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp; __lhs,
       ^
  /usr/include/c++/4.8.2/bits/basic_string.h:2569:5: note:   template argument deduction/substitution failed:
  In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note:   ‘const activationRecord’ is not derived from ‘const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;’
         { return __x &lt; __y; }
                      ^
  In file included from /usr/include/c++/4.8.2/string:52:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/basic_string.h:2581:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; bool std::operator&lt;(const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;, const _CharT*)
       operator&lt;(const basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp; __lhs,
       ^
  /usr/include/c++/4.8.2/bits/basic_string.h:2581:5: note:   template argument deduction/substitution failed:
  In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note:   ‘const activationRecord’ is not derived from ‘const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;’
         { return __x &lt; __y; }
                      ^
  In file included from /usr/include/c++/4.8.2/string:52:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/basic_string.h:2593:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; bool std::operator&lt;(const _CharT*, const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;)
       operator&lt;(const _CharT* __lhs,
       ^
  /usr/include/c++/4.8.2/bits/basic_string.h:2593:5: note:   template argument deduction/substitution failed:
  In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note:   mismatched types ‘const _CharT*’ and ‘activationRecord’
         { return __x &lt; __y; }
                      ^
  In file included from /usr/include/c++/4.8.2/deque:64:0,
                   from /usr/include/c++/4.8.2/queue:60,
                   from Calendar.h:2,
                   from Main.cpp:3:
  /usr/include/c++/4.8.2/bits/stl_deque.h:273:5: note: template&lt;class _Tp, class _Ref, class _Ptr&gt; bool std::operator&lt;(const std::_Deque_iterator&lt;_Tp, _Ref, _Ptr&gt;&amp;, const std::_Deque_iterator&lt;_Tp, _Ref, _Ptr&gt;&amp;)
       operator&lt;(const _Deque_iterator&lt;_Tp, _Ref, _Ptr&gt;&amp; __x,
       ^
  /usr/include/c++/4.8.2/bits/stl_deque.h:273:5: note:   template argument deduction/substitution failed:
  In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note:   ‘const activationRecord’ is not derived from ‘const std::_Deque_iterator&lt;_Tp, _Ref, _Ptr&gt;’
         { return __x &lt; __y; }
                      ^
  In file included from /usr/include/c++/4.8.2/deque:64:0,
                   from /usr/include/c++/4.8.2/queue:60,
                   from Calendar.h:2,
                   from Main.cpp:3:
  /usr/include/c++/4.8.2/bits/stl_deque.h:281:5: note: template&lt;class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR&gt; bool std::operator&lt;(const std::_Deque_iterator&lt;_Tp, _Ref, _Ptr&gt;&amp;, const std::_Deque_iterator&lt;_Tp, _RefR, _PtrR&gt;&amp;)
       operator&lt;(const _Deque_iterator&lt;_Tp, _RefL, _PtrL&gt;&amp; __x,
       ^
  /usr/include/c++/4.8.2/bits/stl_deque.h:281:5: note:   template argument deduction/substitution failed:
  In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note:   ‘const activationRecord’ is not derived from ‘const std::_Deque_iterator&lt;_Tp, _Ref, _Ptr&gt;’
         { return __x &lt; __y; }
                      ^
  In file included from /usr/include/c++/4.8.2/deque:64:0,
                   from /usr/include/c++/4.8.2/queue:60,
                   from Calendar.h:2,
                   from Main.cpp:3:
  /usr/include/c++/4.8.2/bits/stl_deque.h:1975:5: note: template&lt;class _Tp, class _Alloc&gt; bool std::operator&lt;(const std::deque&lt;_Tp, _Alloc&gt;&amp;, const std::deque&lt;_Tp, _Alloc&gt;&amp;)
       operator&lt;(const deque&lt;_Tp, _Alloc&gt;&amp; __x,
       ^
  /usr/include/c++/4.8.2/bits/stl_deque.h:1975:5: note:   template argument deduction/substitution failed:
  In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note:   ‘const activationRecord’ is not derived from ‘const std::deque&lt;_Tp, _Alloc&gt;’
         { return __x &lt; __y; }
                      ^
  In file included from /usr/include/c++/4.8.2/vector:64:0,
                   from /usr/include/c++/4.8.2/queue:61,
                   from Calendar.h:2,
                   from Main.cpp:3:
  /usr/include/c++/4.8.2/bits/stl_vector.h:1420:5: note: template&lt;class _Tp, class _Alloc&gt; bool std::operator&lt;(const std::vector&lt;_Tp, _Alloc&gt;&amp;, const std::vector&lt;_Tp, _Alloc&gt;&amp;)
       operator&lt;(const vector&lt;_Tp, _Alloc&gt;&amp; __x, const vector&lt;_Tp, _Alloc&gt;&amp; __y)
       ^
  /usr/include/c++/4.8.2/bits/stl_vector.h:1420:5: note:   template argument deduction/substitution failed:
  In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note:   ‘const activationRecord’ is not derived from ‘const std::vector&lt;_Tp, _Alloc&gt;’
         { return __x &lt; __y; }
                      ^
  In file included from /usr/include/c++/4.8.2/queue:64:0,
                   from Calendar.h:2,
                   from Main.cpp:3:
  /usr/include/c++/4.8.2/bits/stl_queue.h:286:5: note: template&lt;class _Tp, class _Seq&gt; bool std::operator&lt;(const std::queue&lt;_Tp, _Seq&gt;&amp;, const std::queue&lt;_Tp, _Seq&gt;&amp;)
       operator&lt;(const queue&lt;_Tp, _Seq&gt;&amp; __x, const queue&lt;_Tp, _Seq&gt;&amp; __y)
       ^
  /usr/include/c++/4.8.2/bits/stl_queue.h:286:5: note:   template argument deduction/substitution failed:
  In file included from /usr/include/c++/4.8.2/string:48:0,
                   from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                   from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                   from /usr/include/c++/4.8.2/ios:42,
                   from /usr/include/c++/4.8.2/ostream:38,
                   from /usr/include/c++/4.8.2/iostream:39,
                   from Main.cpp:1:
  /usr/include/c++/4.8.2/bits/stl_function.h:235:20: note:   ‘const activationRecord’ is not derived from ‘const std::queue&lt;_Tp, _Seq&gt;’
         { return __x &lt; __y; }
                      ^
  make: *** [simlib] Error 1
  </code></pre>
  
  <p>The code itself:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  #include "Calendar.h"
  #include "Transaction.h"
  
  using namespace std;
  
  int main() {
  
      Calendar *calendar = new Calendar();
      calendar-&gt;init(0, 300);
      calendar-&gt;push(0,1, new Transaction(calendar));
      calendar-&gt;run();
  }
  
  ----------CALENDAR.H----------
  
  #include &lt;iostream&gt;
  #include &lt;queue&gt;
  
  using namespace std;
  
  class Transaction;
  
  struct activationRecord {
  
      double time;
      int priority;
      Transaction *transaction;
  };
  
  class Calendar {
  
      private:
          double timeStop;
          double time;
          priority_queue&lt;activationRecord&gt; activationCalendar;
  
      public:
          bool isEmpty();
          void push(double, int, Transaction*);
          void pop();
          void run();
          void init(double, double);
  
          double getTime();
  
          activationRecord top();
  };
  
  ----------CALENDAR.CPP----------
  
  #include &lt;iostream&gt;
  
  #include "Calendar.h"
  #include "Transaction.h"
  
  using namespace std;
  
  bool Calendar::isEmpty() {
  
      return activationCalendar.empty();
  }
  
  void Calendar::pop() {
  
      activationCalendar.pop();
  }
  
  void Calendar::push(double t, int p, Transaction *tr) {
  
      activationRecord r;
  
      r.priority = p;
      r.time = t;
      r.transaction = tr;
  
      activationCalendar.push(r);
  }
  
  activationRecord Calendar::top() {
  
      return activationCalendar.top();
  }
  
  void Calendar::run() {
  
      activationRecord r;
  
  
      while(!activationCalendar.empty()) {
  
  
          r = activationCalendar.top();
          activationCalendar.pop();
  
  
          if(r.time &gt; timeStop) {
              time = timeStop;
              break;
          }
  
          //Posun cas na cas aktualniho eventu
          time = r.time;
  
          cout &lt;&lt; "Time: " &lt;&lt; time &lt;&lt; " ";
  
          //Vykonej event
          (*r.transaction).choose();
      }
  }
  
  
  void Calendar::init(double start, double stop) {
  
       time = start;
       timeStop = stop;
  }
  
  double Calendar::getTime() {
  
      return time;
  }
  
  
  bool operator &lt;(const activationRecord &amp; a, const activationRecord &amp; b)
  {
      return a.time &gt; b.time;
  }
  
  ----------TRANSACTION.H----------
  
  #include &lt;iostream&gt;
  
  using namespace std;
  
  class Calendar;
  
  class Transaction {
  
      private:
          int chooser;
          Calendar *cal;
  
      public:
          Transaction(Calendar*);
          ~Transaction();
  
          void choose();
          void event1();
          void event2();
          void event3();
          void event4();
  };
  ----------TRANSACTION.CPP----------
  
  #include &lt;iostream&gt;
  
  #include "Transaction.h"
  #include "Calendar.h"
  
  using namespace std;
  
  
  Transaction::Transaction(Calendar *c) {
  
      this-&gt;cal = c;
      this-&gt;chooser = 1;
  }
  
  void Transaction::choose() {
  
      switch(chooser){
          case(1):
              event1();
              break;
          case(2):
              event2();
              break;
          case(3):
              event3();
              break;
          case(4):
              event4();
              break;
      }
  }
  
  
  void Transaction::event1() {
  
      cout &lt;&lt; "Event1::Transakce" &lt;&lt; this &lt;&lt; endl;
  
      chooser = 2;
  
  
      cal-&gt;push(cal-&gt;getTime()+200, 1, new Transaction(cal));
  
  
      cal-&gt;push(cal-&gt;getTime(), 1, this);
  }
  
  void Transaction::event2() {
  
      cout &lt;&lt; "Event2::Transakce" &lt;&lt; this &lt;&lt; endl;
  
      chooser = 3;
  
      cal-&gt;push(cal-&gt;getTime()+50, 1, this);
  }
  
  void Transaction::event3() {
  
      cout &lt;&lt; "Event3::Transakce" &lt;&lt; this &lt;&lt; endl;
  
      chooser = 4;
  
      cal-&gt;push(cal-&gt;getTime(), 1, this);
  
  }
  
  void Transaction::event4() {
  
      cout &lt;&lt; "Event4::Transakce" &lt;&lt; this &lt;&lt; endl;
  
  }
  </code></pre>