c++ - Can't sort unordered_set -


i have unordered_set of class activestatuseffect set declared follows:

boost::unordered_set<statuseffects::activestatuseffect> activestatuseffects; 

activestatuseffect defined follows:

class activestatuseffect     {     public:         statuseffect* effect;         int reminaingturns;         bool operator<(const activestatuseffect& ase) const         {             return *effect < *ase.effect;         }         bool operator>(const activestatuseffect& ase) const         {             return *effect > *ase.effect;         }         bool operator==(const activestatuseffect& ase) const         {             return *effect == *ase.effect;         }         bool operator!=(const activestatuseffect& ase) const         {             return !((*this) == ase);         }     }; 

the comparison between statuseffect's comparison between unique integer assinged each instance of status effect.

however, if try sort effects follows:

std::sort(statusset.begin(), statusset.end(), [](statuseffects::activestatuseffect const &se1, statuseffects::activestatuseffect const &se2){return se1.effect->getpriority() < se2.effect->getpriority();}); 

i many errors in algorithm header file such

error 198 error c2784: '_base1::difference_type std::operator -(const std::_revranit<_ranit,_base> &,const std::_revranit<_ranit2,_base2> &)' : not deduce template argument 'const std::_revranit<_ranit,_base> &' 'boost::unordered_detail::hash_const_iterator' c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3806

error 199 error c2784: '_base1::difference_type std::operator -(const std::_revranit<_ranit,_base> &,const std::_revranit<_ranit2,_base2> &)' : not deduce template argument 'const std::_revranit<_ranit,_base> &' 'boost::unordered_detail::hash_const_iterator' c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3806

why not able sort set? i'm quite unordered_set removing attempts sort or changing vector not generate errors.

boost::unordered_set<foo> a; a.insert(...); ...  std::set<foo> b(a.begin(), a.end());  std::set<foo> c; std::copy(a.begin(), a.end(), std::inserter(c, c.end()); 

voilĂ , sorted set.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -