Similar to the link below,
https://stackoverflow.com/a/30424281/1442787
I have my class Point
with member variables double x,y,z
.
I have overloaded operator <
in my class to insert values into std::map
bool Point::operator<(const Point &p)const{
return ( x < p.x
|| ( x == p.x
&& ( y < p.y
|| ( y == p.y
&& z < p.z))));
}
I have defined my map with Point class as key and std::pair
as value
typedef std::pair<int,int> mypair;
typedef std::map<Point, mypair> mymap;
std::map
does not allow the insertion of duplicate keys.
But,in my code, while inserting the key/value pair, the duplicate key is also getting inserted as shown below
map:0.436612,16.527741,0.000000,22,2 map:0.454781,17.427262,15.264347,74,12 map:0.454781,17.427262,15.264347,27,11 map:0.608370,17.373443,20.124160,21,13 map:0.608370,17.373443,20.124160,69,11
What could be the reason for duplicate insertion?