Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5839737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:37:45+00:00 2026-05-22T11:37:45+00:00

I have an unordered_set of a class ActiveStatusEffect The set is declared as follows:

  • 0

I have an unordered_set of a class ActiveStatusEffect The set is declared as follows:

boost::unordered_set<StatusEffects::ActiveStatusEffect> ActiveStatusEffects;

ActiveStatusEffect is defined as 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 is a comparison between a unique integer assinged to each instance of a status effect.

However, if I try to sort the effects like follows:

std::sort(statusSet.begin(), statusSet.end(), [](StatusEffects::ActiveStatusEffect const &se1, StatusEffects::ActiveStatusEffect const &se2){return se1.effect->GetPriority() < se2.effect->GetPriority();});

I get many errors in the algorithm header file such as

Error 198 error C2784:
‘_Base1::difference_type std::operator
-(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2>
&)’ : could not deduce template
argument for ‘const
std::_Revranit<_RanIt,_Base> &’ from
‘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>
&)’ : could not deduce template
argument for ‘const
std::_Revranit<_RanIt,_Base> &’ from
‘boost::unordered_detail::hash_const_iterator’ c:\program
files (x86)\microsoft visual studio
10.0\vc\include\algorithm 3806

Why am I not able to sort the set? I’m quite certain this is something about unordered_set as removing attempts to sort or changing it to a vector does not generate errors.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:37:46+00:00Added an answer on May 22, 2026 at 11:37 am
    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à, a sorted set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have an unordered set unordered_set<int> my_set; myset.insert(1); myset.insert(2); myset.insert(3); How do I
I have a class like this public class HistoryEntry { DateTime Date{ get; protected
I have a privately scoped Boost.BiMap in a class, and I would like to
I have an unordered list which is set to overflow: hidden . The width
I have a set of list items in unordered lists that I bind the
I have a set of bitsets pointers in an unordered_map static unordered_map< size_t, bitset<BITSIZE>*
I have an unordered list... <ul class=hide> <li class=home> <div class=link> <a href=/>Home</a> </div>
I have an unordered_map (in C++) that pairs an int with an object of
I have an unordered list: <div class=toplist> <ul> <li>Item</li> <li>Item</li> <li>Item</li> <li>Item</li> <li>Item</li> <li>Item</li>
I have a set of <li> elements in an unordered list. The items are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.