Hello all,
In the code below, can anybody see that I am violating any of the rules that
types must abide by to be held in containers? I get a memory access problem
when a ZoneSetsType destructs...
Thanks,
Dave
struct OnePolygonType
{
unsigned int ModTime;
std::string Pts;
std::string Type;
unsigned int Id; // Unused in comparing objects
// Implement a strict weak ordering
bool operator<(const OnePolygonType &rhs) const
{
if (ModTime < rhs.ModTime)
return true;
else if (ModTime > rhs.ModTime)
return false;
if (Pts < rhs.Pts)
return true;
else if (Pts > rhs.Pts)
return false;
if (Type < rhs.Type)
return true;
else if (Type > rhs.Type)
return false;
return false;
}
bool operator==(const OnePolygonType &rhs) const
{
return (
(ModTime == rhs.ModTime) &&
(Pts == rhs.Pts) &&
(Type == rhs.Type)
);
}
};
typedef std::set<OnePolygonType> PolygonSetType;
struct ZoneSetType
{
PolygonSetType SafeZones;
PolygonSetType HotZones;
// Implement a strict weak ordering
bool operator<(const ZoneSetType &rhs) const
{
if (SafeZones < rhs.SafeZones)
return true;
else if (SafeZones > rhs.SafeZones)
return false;
if (HotZones < rhs.HotZones)
return true;
else if (HotZones > rhs.HotZones)
return false;
return false;
}
bool operator==(const ZoneSetType &rhs) const
{
return (
(SafeZones == rhs.SafeZones) &&
(HotZones == rhs.HotZones)
);
}
};
typedef std::map<std::string, ZoneSetType> ZoneSetsType;