problem sorting a set - c++

This is a discussion on problem sorting a set - c++ ; I have problems compiling the ff line: std::sort(sequence_set.begin(), sequence_set.end()); Error 2 error C2784: 'reverse_iterator<_RanIt>::difference_type std: perator -(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::_Tree<_Traits>::iterator' c:\program files\microsoft visual studio 8\vc\include\algorithm 2754 The ...

+ Reply to Thread
Results 1 to 2 of 2

problem sorting a set

  1. Default problem sorting a set

    I have problems compiling the ff line:

    std::sort(sequence_set.begin(), sequence_set.end());


    Error 2 error C2784: 'reverse_iterator<_RanIt>::difference_type
    std:perator -(const std::reverse_iterator<_RanIt> &,const
    std::reverse_iterator<_RanIt2> &)' : could not deduce template argument
    for 'const std::reverse_iterator<_RanIt> &' from
    'std::_Tree<_Traits>::iterator' c:\program files\microsoft visual
    studio 8\vc\include\algorithm 2754


    The variable sequence_set is of type std::set, and contains classes
    which have the ff comparison operators defined:

    '==', '>', and '<' (equality, greater than and less than)




  2. Default Re: problem sorting a set

    On Oct 16, 7:00 pm, Anonymous <no.re...@here.com> wrote:

    > I have problems compiling the ff line:
    >
    > std::sort(sequence_set.begin(), sequence_set.end());
    >
    > Error 2 error C2784: 'reverse_iterator<_RanIt>::difference_type
    > std:perator -(const std::reverse_iterator<_RanIt> &,const
    > std::reverse_iterator<_RanIt2> &)' : could not deduce template argument
    > for 'const std::reverse_iterator<_RanIt> &' from
    > 'std::_Tree<_Traits>::iterator' c:\program files\microsoft visual
    > studio 8\vc\include\algorithm 2754
    >
    > The variable sequence_set is of type std::set, and contains classes
    > which have the ff comparison operators defined:
    >
    > '==', '>', and '<' (equality, greater than and less than)


    A std::set is already sorted, and you cannot rearrange the ordering of
    the elements within it. For that matter, std::sort requires random
    access iterators, which a std::set does not have. Hence, you cannot
    call std::sort on it.

    Perhaps you should explain what it is you are trying to accomplish.

    Best regards,

    Tom


+ Reply to Thread

Similar Threads

  1. strange problem of sorting
    By Application Development in forum c++
    Replies: 7
    Last Post: 07-08-2007, 08:31 AM
  2. Problem with XSL and sorting
    By Application Development in forum XML SOAP
    Replies: 3
    Last Post: 09-09-2006, 10:57 AM
  3. Sorting numbergroups problem
    By Application Development in forum Java-Games
    Replies: 2
    Last Post: 08-06-2005, 08:22 PM
  4. Problem in update datagrid after sorting
    By Application Development in forum DOTNET
    Replies: 0
    Last Post: 08-26-2004, 08:21 PM
  5. Sorting strings problem
    By Application Development in forum Java
    Replies: 2
    Last Post: 06-01-2004, 05:32 PM