"Robert William Vesterman" <> wrote...
> I'm trying to use the version of list.sort that takes a comparison
> parameter. I can't get it to compile on one particular platform - on
> another platform it's fine. Here's what I'm doing reduced to a simple
> example:
>
> #include <list>
>
> using namespace std;
>
> struct comp
> {
> bool operator() ( const int *lhs, const int *rhs ) const
> {
> return *lhs < *rhs;
> }
> };
>
> int main()
> {
> list<int *> blah = list<int *>();
> blah.sort ( comp() );
> return 0;
> }
>
> When I try to compile that (on this one particular platform), the
> compiler tells me that blah.sort() is being passed too many arguments.
> On the other platform, it compiles fine.
>
> The STL documentation for the offending platform claims to support
> list.sort ( compare ), specifically:
>
> template <class Compare> void sort ( Compare comp);
>
> Any idea what's wrong?
Yes. Two things can be wrong: the documentation and the newsgroup
you're posting to. You should either pick a different library
implementation, or complain to your compiler vendor about the
documentation being incorrect. In any case, your code if fine
as far as C++ is concerned. Perhaps you can get more help in
a forum dedicated to programming on "this one particular platform"
or devoted to the compiler you're using on that platform...
Victor
|