Re: list.sort ( compare )

Discussion in 'C++' started by Victor Bazarov, Jun 26, 2003.

  1. "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
     
    Victor Bazarov, Jun 26, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. edw
    Replies:
    2
    Views:
    9,474
  2. Frank & Janny Plaza
    Replies:
    4
    Views:
    624
    Kenneth Hutson
    Sep 23, 2003
  3. Replies:
    7
    Views:
    741
    Stefan Arentz
    Sep 10, 2007
  4. Jeremy
    Replies:
    1
    Views:
    244
    Chris Rebert
    Feb 24, 2011
  5. Navin
    Replies:
    1
    Views:
    698
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page