#ifndef POINT_2D_H #define POINT_2D_H #include class point2D_t { // Simple {x,y} datastructure = std::tuple... using point_datatype_t = typename std::tuple; point_datatype_t point_vector{}; explicit point2D_t(const point_datatype_t pt) : point_vector{pt} {} public: enum class PointCoord { COORD_X, COORD_Y }; point2D_t() = default; point2D_t(const int x, const int y) : point2D_t(std::make_tuple(x, y)) {} template int get() const { return std::get(dimension)>(point_vector); } template void set(int value) { std::get(dimension)>(point_vector) = value; } point_datatype_t get() const { return point_vector; } void set(point_datatype_t value) { point_vector = value; } void set(const int x, const int y) { set(std::make_tuple(x, y)); } point2D_t &operator+=(const point2D_t &pt) { this->point_vector = std::make_tuple( get() + pt.get(), get() + pt.get()); return *this; } point2D_t &operator-=(const point2D_t &pt) { this->point_vector = std::make_tuple( get() - pt.get(), get() - pt.get()); return *this; } }; inline point2D_t operator+(point2D_t l, const point2D_t &r) { l += r; return l; } inline point2D_t operator-(point2D_t l, const point2D_t &r) { l -= r; return l; } #endif