#include <algorithm>

// Dane są poniższe klasy. Zaimplementuj funkcję "leftEdge", która pobiera wektor
// zawierający zestaw tych figur i zwraca wartość, która reprezentuje wartość x
// skrajnie lewego punktu zajmowanego przez ten zestaw figur.

struct Point { double x, y; };

struct Rectangle { Point topLeft, bottomRight; };

struct Circle { Point centre; double radius; };


// Rozwiązanie:

#include <variant>
#include <optional>
#include <vector>
#include <algorithm>

using Shape = std::variant<Rectangle, Circle>;

struct LeftBorder {
  double operator()(const Rectangle& rect) const {
    return rect.topLeft.x;
  }
  double operator()(const Circle& circle) const {
    return circle.centre.x - circle.radius;
  }
};


std::optional<double> leftEdge(const std::vector<Shape> & shapes) {
    if (shapes.empty()) { return {}; }
    auto compareMin = [](const Shape& lhs, const Shape& rhs) {
        return std::visit(LeftBorder{}, lhs) < std::visit(LeftBorder{}, rhs);
    };
    auto min = std::min_element(shapes.begin(), shapes.end(), compareMin);
    return std::visit(LeftBorder{}, *min);
}

int main(){

	return 0;

}
