On 22 July 2012 04:09, Nicholas Mario Wardhana
Oops, I made a mistake. I just input "1" in my previous e-mail, so I changed it to "1 2 3", and this is what I get:
Does it reach EOF? yes Is it bad? no Does it fail? no Is it good? no
So it reaches EOF, and it is not good.
The updated code and the output are at the end of this e-mail. It seems like the graphviz and lexical_cast cases suffer from setting the failbit, whereas the istringstream case sets the eofbit. No flag is set in the std::cin case.
Thanks!
Best regards, Nicholas
I finally solved this problem. The correct, at least better, way to save/read the data is like mentioned in http://stackoverflow.com/questions/10382884/c-using-classes-with-boostlexica... , which in my case becomes //==================================== inline friend std::ostream& operator << ( std::ostream& o, const Vec3& v ) { o << v.x << " " << v.y << " " << v.z; return o; } inline friend std::istream& operator >> ( std::istream& i, Vec3& v ) { i >> v.x; if((i.flags() & std::ios_base::skipws) == 0) { char whitespace; i >> whitespace; } i >> v.y; if((i.flags() & std::ios_base::skipws) == 0) { char whitespace; i >> whitespace; } i >> v.z; return i; } //==================================== This has also apparently been a topic of discussion for quite some time. http://lists.boost.org/Archives/boost/2005/01/79275.php Thank you again! Best regards, Nicholas