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 ...
-
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)
-
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
Similar Threads
-
By Application Development in forum c++
Replies: 7
Last Post: 07-08-2007, 08:31 AM
-
By Application Development in forum XML SOAP
Replies: 3
Last Post: 09-09-2006, 10:57 AM
-
By Application Development in forum Java-Games
Replies: 2
Last Post: 08-06-2005, 08:22 PM
-
By Application Development in forum DOTNET
Replies: 0
Last Post: 08-26-2004, 08:21 PM
-
By Application Development in forum Java
Replies: 2
Last Post: 06-01-2004, 05:32 PM