making the compiler generate regular operators

Started by
0 comments, last by billybob 21 years ago
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?
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.

This topic is closed to new replies.

Advertisement