Is there a built in type to store UNordered pairs?
ie. I want these
pair<double, double> a(4.0, 5.0);
pair<double, double> a(5.0, 4.0);
to be equal. Do I have to make a wrapper and override == ?
Thanks,
Dave
Is there a built in type to store UNordered pairs?
ie. I want these
pair<double, double> a(4.0, 5.0);
pair<double, double> a(5.0, 4.0);
to be equal. Do I have to make a wrapper and override == ?
Thanks,
Dave
I don't believe there is a built in type to do such a thing (I've never come across anything like that anyway), but you should be able to write your own function to make sure they are equal anyway.
bool equal ( /* pair p1 and p2 */)
{ /*check if p1 first and p2 first are equal
if so, check if p1 second and p2 second are equal
if so, return true
if 1st check not, check if p1 first and p2 second are equal
if so, check if p1 second and p2 first are equal
if so, return true
return false otherwise */
}
I think that would handle each case, but you'd have to test it to make sure.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.