Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

billybob

making the compiler generate regular operators

This topic is 5721 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have a simple union for the ID of my objects:
union UObjectID
{
   struct
   {
      unsigned long ID : 24;
      unsigned char Client : 8;
   };
   unsigned long Packed;
};
 
now i''m trying to use it in std::* containers, but its complaining about not having a < operator. is there a way to make the compiler generate the operators for such a simple type?

Share this post


Link to post
Share on other sites
Advertisement
No, because "less than" has no meaning for your custom objects. The compiler has no idea how it''s supposed to compare two instances of your type and see if one is less than another, so you have to define the operator yourself.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!