#include template struct point { T x, y; }; template std::ostream &operator<<(std::ostream &os, point const & p) { os << "(" << p.x << "," << p.y << ")"; return os; } template std::istream &operator>>(std::istream &is, point & p) { char c = 0; is >> c; if( c != '(') { is.setstate(std::ios_base::failbit); return is; } is >> p.x; is >> c; if( c != ',') { is.setstate(std::ios_base::failbit); return is; } is >> p.y; is >> c; if( c != ')') { is.setstate(std::ios_base::failbit); return is; } return is; } template point operator+(point const & lhs, point const & rhs) { point p = {lhs.x + rhs.x, rhs.y + rhs.y}; return p; } int main() { point p1 = {1, 2}; point p2 = {3, 4}; point p3 = {0, 0}; p3 = p2 + p1; p1 = boost::convert >::from("(1,2)"); p1 = boost::convert >::from("(3,4)"); point p4 = boost::convert >::from("(1,2)") + boost::convert >::from("(3,4)"); }