I want to have a set<double> S;
and insert some doubles into it. but I want the set to consider 1.0000001 == 1.0000000
(comparing doubles using epsilon) (I mean if I insert both of the numbers to the set, set.size() should equal to one). I know how to pass the operator() (for comparing) to the set but I don't know how to pass the function:
const double eps = 1e-8;
bool operator==(double a, double b)
{
return abs(a - b) < eps;
}
to the set.
P.S: Thanks to Sid. @Sid: I found out that: operator== is not used by std::set. Elements a and b are considered equal iff !(a < b) && !(b < a).