problem sorting a set

A

Anonymous

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::eek: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)
 
T

Thomas Tutone

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::eek: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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top