Simple Vector Library 1.5 http://www.cs.cmu.edu/~ajw/doc/svl.html
Vec2.cpp
- Committer:
- BartJanssens
- Date:
- 2016-01-05
- Revision:
- 1:e25ff4b06ed2
- Parent:
- 0:785cff1e5a7c
File content as of revision 1:e25ff4b06ed2:
/* File: Vec2.cpp Function: Implements Vec2.h Author(s): Andrew Willmott Copyright: (c) 1995-2001, Andrew Willmott */ #include "Vec2.h" //#include <cctype> //#include <iomanip> /* ostream &operator << (ostream &s, const Vec2 &v) { uint16_t w = s.width(); return(s << '[' << v[0] << ' ' << setw(w) << v[1] << ']'); } istream &operator >> (istream &s, Vec2 &v) { Vec2 result; Char c; // Expected format: [1 2] while (s >> c && isspace(c)) ; if (c == '[') { s >> result[0] >> result[1]; if (!s) { cerr << "Error: Expected number while reading vector\n"; return(s); } while (s >> c && isspace(c)) ; if (c != ']') { s.clear(ios::failbit); cerr << "Error: Expected ']' while reading vector\n"; return(s); } } else { s.clear(ios::failbit); cerr << "Error: Expected '[' while reading vector\n"; return(s); } v = result; return(s); } */