Re: STL sort not working??

From: Stewart Tootill (stewart.tootill_at_softel.co.uk)
Date: 10/10/03


Date: 10 Oct 2003 04:23:27 -0700


<snip>

> main.cpp:44: instantiated from here
> /usr/include/c++/3.2.2/bits/stl_algo.h:2004: no match for `
> std::_List_iterator<HuffmanNode, HuffmanNode&, HuffmanNode*>& +
> int'
> operator
> /usr/include/c++/3.2.2/bits/stl_algo.h:2079: instantiated from `void
> std::__final_insertion_sort(_RandomAccessIter, _RandomAccessIter,
> _Compare) [with _RandomAccessIter = std::_List_iterator<HuffmanNode,
> HuffmanNode&, HuffmanNode*>, _Compare = bool (*)(const HuffmanNode&,
> const HuffmanNode&)]'
> /usr/include/c++/3.2.2/bits/stl_algo.h:2210: instantiated from `void
> std::sort(_RandomAccessIter, _RandomAccessIter, _Compare) [with
> _RandomAccessIter = std::_List_iterator<HuffmanNode, HuffmanNode&,
> HuffmanNode*>, _Compare = bool (*)(const HuffmanNode&, const
> HuffmanNode&)]'
> main.cpp:44: instantiated from here
> /usr/include/c++/3.2.2/bits/stl_algo.h:2008: no match for `
> std::_List_iterator<HuffmanNode, HuffmanNode&, HuffmanNode*>& +
> int'
> operator
>
>

< snip the code >

I haven't looked at the docs to check this, but it appears from the
errors that sort requires a random access iterator, and that list
iterators are not random access. I can't remember from your code
whether you need a list specifically, but try a vector, where the
iterators are definitely random access.

Yours,

Stewart Tootill



Relevant Pages