Changed input operator.
authordeba
Wed, 27 Apr 2005 10:37:03 +0000
changeset 1392b87aa8f0feb8
parent 1391 5b46af577b23
child 1393 2edd8cd06eaf
Changed input operator.
src/lemon/xy.h
     1.1 --- a/src/lemon/xy.h	Tue Apr 26 15:50:30 2005 +0000
     1.2 +++ b/src/lemon/xy.h	Wed Apr 27 10:37:03 2005 +0000
     1.3 @@ -159,11 +159,25 @@
     1.4    ///\relates xy
     1.5    ///
     1.6    template<typename T>
     1.7 -  inline
     1.8 -  std::istream& operator>>(std::istream &is, xy<T> &z)
     1.9 -  {
    1.10 -
    1.11 -    is >> z.x >> z.y;
    1.12 +  inline std::istream& operator>>(std::istream &is, xy<T> &z) {
    1.13 +    char c;
    1.14 +    if (is >> c) {
    1.15 +      if (c != '(') is.putback(c);
    1.16 +    } else {
    1.17 +      is.clear();
    1.18 +    }
    1.19 +    if (!(is >> z.x)) return is;
    1.20 +    if (is >> c) {
    1.21 +      if (c != ',') is.putback(c);
    1.22 +    } else {
    1.23 +      is.clear();
    1.24 +    }
    1.25 +    if (!(is >> z.y)) return is;
    1.26 +    if (is >> c) {
    1.27 +      if (c != ')') is.putback(c);
    1.28 +    } else {
    1.29 +      is.clear();
    1.30 +    }
    1.31      return is;
    1.32    }
    1.33  
    1.34 @@ -173,8 +187,7 @@
    1.35    ///\relates xy
    1.36    ///
    1.37    template<typename T>
    1.38 -  inline
    1.39 -  std::ostream& operator<<(std::ostream &os, xy<T> z)
    1.40 +  inline std::ostream& operator<<(std::ostream &os, const xy<T>& z)
    1.41    {
    1.42      os << "(" << z.x << ", " << z.y << ")";
    1.43      return os;