title: Compare two stl lists in c++
body: <p>I have the following code:</p>
  
  <pre><code>IndexedData index(strUrl);// IndexedData is a class.
  jsonParser-&gt;parse(strTags,index,ret); 
  
  std::list&lt;odIndexedDataNode&gt; tags; // so index.tags is a STL list.
  
  std::list&lt;odIndexedDataNode&gt; testListIdns;
  insertTags(testListIdns);
  </code></pre>
  
  <p>This testListIdns is also a STL list. I want to compare index.tags and testListIdns are equal.</p>
  
  <p>I wrote this function:</p>
  
  <pre><code>bool isEqual(std::list&lt;odIndexedDataNode&gt; &amp;tags, std::list&lt;odIndexedDataNode&gt; &amp;testListIdns) {
      if(tags.size() == testListIdns.size())
          return std::equal(tags.begin(), tags.end(), testListIdns.begin());
      else
          return false;
  }
  </code></pre>
  
  <p>But it gives the following compilation error. Can anybody help me?</p>
  
  <pre><code>In file included from /usr/include/c++/4.6/bits/char_traits.h:41:0,
                   from /usr/include/c++/4.6/ios:41,
                   from /usr/include/c++/4.6/istream:40,
                   from /usr/include/c++/4.6/sstream:39,
                   from /root/target/include/boost/test/utils/wrap_stringstream.hpp:26,
                   from /root/target/include/boost/test/predicate_result.hpp:20,
                   from /root/target/include/boost/test/test_tools.hpp:19,
                   from /root/target/include/boost/test/unit_test.hpp:19,
                   from configuration_test.cpp:11:
  /usr/include/c++/4.6/bits/stl_algobase.h: In static member function ‘static bool std::__equal&lt;_BoolType&gt;::equal(_II1, _II1, _II2) [with _II1 = std::_List_iterator&lt;Rubicon::odIndexedDataNode&gt;, _II2 = std::_List_iterator&lt;Rubicon::odIndexedDataNode&gt;, bool _BoolType = false]’:
  /usr/include/c++/4.6/bits/stl_algobase.h:820:71:   instantiated from ‘bool std::__equal_aux(_II1, _II1, _II2) [with _II1 = std::_List_iterator&lt;Rubicon::odIndexedDataNode&gt;, _II2 = std::_List_iterator&lt;Rubicon::odIndexedDataNode&gt;]’
  /usr/include/c++/4.6/bits/stl_algobase.h:1022:37:   instantiated from ‘bool std::equal(_II1, _II1, _II2) [with _II1 = std::_List_iterator&lt;Rubicon::odIndexedDataNode&gt;, _II2 = std::_List_iterator&lt;Rubicon::odIndexedDataNode&gt;]’
  configuration_test.cpp:58:67:   instantiated from here
  /usr/include/c++/4.6/bits/stl_algobase.h:791:6: error: no match for ‘operator==’ in ‘__first1.std::_List_iterator&lt;_Tp&gt;::operator* [with _Tp = Rubicon::odIndexedDataNode, std::_List_iterator&lt;_Tp&gt;::reference = Rubicon::odIndexedDataNode&amp;]() == __first2.std::_List_iterator&lt;_Tp&gt;::operator* [with _Tp = Rubicon::odIndexedDataNode, std::_List_iterator&lt;_Tp&gt;::reference = Rubicon::odIndexedDataNode&amp;]()’
  /usr/include/c++/4.6/bits/stl_algobase.h:791:6: note: candidates are:
  /usr/include/c++/4.6/bits/postypes.h:218:5: note: template&lt;class _StateT&gt; bool std::operator==(const std::fpos&lt;_StateT&gt;&amp;, const std::fpos&lt;_StateT&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_pair.h:201:5: note: template&lt;class _T1, class _T2&gt; bool std::operator==(const std::pair&lt;_T1, _T2&gt;&amp;, const std::pair&lt;_T1, _T2&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_iterator.h:285:5: note: template&lt;class _Iterator&gt; bool std::operator==(const std::reverse_iterator&lt;_Iterator&gt;&amp;, const std::reverse_iterator&lt;_Iterator&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_iterator.h:335:5: note: template&lt;class _IteratorL, class _IteratorR&gt; bool std::operator==(const std::reverse_iterator&lt;_IteratorL&gt;&amp;, const std::reverse_iterator&lt;_IteratorR&gt;&amp;)
  /usr/include/c++/4.6/bits/allocator.h:122:5: note: template&lt;class _T1, class _T2&gt; bool std::operator==(const std::allocator&lt;_T1&gt;&amp;, const std::allocator&lt;_T2&gt;&amp;)
  /usr/include/c++/4.6/bits/allocator.h:127:5: note: template&lt;class _Tp&gt; bool std::operator==(const std::allocator&lt;_Tp1&gt;&amp;, const std::allocator&lt;_Tp1&gt;&amp;)
  /usr/include/c++/4.6/bits/basic_string.h:2427:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; bool std::operator==(const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;, const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;)
  /usr/include/c++/4.6/bits/basic_string.h:2434:5: note: template&lt;class _CharT&gt; typename __gnu_cxx::__enable_if&lt;std::__is_char&lt;_Tp&gt;::__value, bool&gt;::__type std::operator==(const std::basic_string&lt;_CharT&gt;&amp;, const std::basic_string&lt;_CharT&gt;&amp;)
  /usr/include/c++/4.6/bits/basic_string.h:2448:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; bool std::operator==(const _CharT*, const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;)
  /usr/include/c++/4.6/bits/basic_string.h:2460:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; bool std::operator==(const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;, const _CharT*)
  /usr/include/c++/4.6/bits/streambuf_iterator.h:194:5: note: template&lt;class _CharT, class _Traits&gt; bool std::operator==(const std::istreambuf_iterator&lt;_CharT, _Traits&gt;&amp;, const std::istreambuf_iterator&lt;_CharT, _Traits&gt;&amp;)
  /usr/include/c++/4.6/bits/stream_iterator.h:130:5: note: template&lt;class _Tp, class _CharT, class _Traits, class _Dist&gt; bool std::operator==(const std::istream_iterator&lt;_Tp, _CharT, _Traits, _Dist&gt;&amp;, const std::istream_iterator&lt;_Tp, _CharT, _Traits, _Dist&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_list.h:275:5: note: template&lt;class _Val&gt; bool std::operator==(const std::_List_iterator&lt;_Tp&gt;&amp;, const std::_List_const_iterator&lt;_Val&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_list.h:1564:5: note: template&lt;class _Tp, class _Alloc&gt; bool std::operator==(const std::list&lt;_Tp, _Alloc&gt;&amp;, const std::list&lt;_Tp, _Alloc&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_vector.h:1273:5: note: template&lt;class _Tp, class _Alloc&gt; bool std::operator==(const std::vector&lt;_Tp, _Alloc&gt;&amp;, const std::vector&lt;_Tp, _Alloc&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_tree.h:309:5: note: template&lt;class _Val&gt; bool std::operator==(const std::_Rb_tree_iterator&lt;_Tp&gt;&amp;, const std::_Rb_tree_const_iterator&lt;_Val&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_tree.h:856:5: note: template&lt;class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc&gt; bool std::operator==(const std::_Rb_tree&lt;_Key, _Val, _KeyOfValue, _Compare, _Alloc&gt;&amp;, const std::_Rb_tree&lt;_Key, _Val, _KeyOfValue, _Compare, _Alloc&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_map.h:882:5: note: template&lt;class _Key, class _Tp, class _Compare, class _Alloc&gt; bool std::operator==(const std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp;, const std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_multimap.h:800:5: note: template&lt;class _Key, class _Tp, class _Compare, class _Alloc&gt; bool std::operator==(const std::multimap&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp;, const std::multimap&lt;_Key, _Tp, _Compare, _Alloc&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_deque.h:246:5: note: template&lt;class _Tp, class _Ref, class _Ptr&gt; bool std::operator==(const std::_Deque_iterator&lt;_Tp, _Ref, _Ptr&gt;&amp;, const std::_Deque_iterator&lt;_Tp, _Ref, _Ptr&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_deque.h:253:5: note: template&lt;class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR&gt; bool std::operator==(const std::_Deque_iterator&lt;_Tp, _RefL, _PtrL&gt;&amp;, const std::_Deque_iterator&lt;_Tp, _RefR, _PtrR&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_deque.h:1917:5: note: template&lt;class _Tp, class _Alloc&gt; bool std::operator==(const std::deque&lt;_Tp, _Alloc&gt;&amp;, const std::deque&lt;_Tp, _Alloc&gt;&amp;)
  /usr/include/c++/4.6/bits/stl_stack.h:241:5: note: template&lt;class _Tp, class _Seq&gt; bool std::operator==(const std::stack&lt;_Tp, _Seq&gt;&amp;, const std::stack&lt;_Tp, _Seq&gt;&amp;)
  </code></pre>