Expanding DistProxy to something more useful

Now that we have the basis, we want to make the DistProxy class more useful. For example, the user might actually want to utilize the received distance or compare it with other distances.

Let's expand the DistProxy class accordingly, with a comparator to another DistProxy class and an implicit cast to float:

class DistProxy{public:  DistProxy(float x0, float y0, float x1, float y1)  : dist_sqrd_{std::pow(x0 - x1, 2) + std::pow(y0 - y1, 2)}  {}  auto operator==(const DistProxy& dp) const {     return dist_sqrd_ == dp.dist_sqrd_; }  auto operator<(const DistProxy& dp) const {     return dist_sqrd_ < dp.dist_sqrd_; }  auto operator<(float dist) const {     return dist_sqrd_ < dist*dist; }  // Implicit cast to float ...

Get C++ High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.