
john@thesalmons.org wrote:
I am having some trouble with lexical_cast that I think illustrates a problem with the underlying implementation. My basic problem is that I'd like lexical_cast to "work" for user-defined types (UDTs) that conform to lexical_cast's documented specification of OutputStreamable, InputStreamable, CopyConstructible and DefaultConstructible.
[ skiped ]
std::istream& operator>>(std::istream& s, Udt& u){ return s >> u.a >> u.b; }
I believe that this implementation is incorrect. If you put a writespace in output operator, you should be prepared for skipws flag and read the writespace explicitly: std::istream& operator>>(std::istream& s, Udt& u){ s >> u.a; if((s.flags() & std::ios_base::skipws) == 0) { char whitespace; s >> whitespace; } return s >> u.b; } -- Alexander Nasonov http://nasonov.blogspot.com There comes a time in every rightly constructed boy`s life when he has a raging desire to go somewhere and dig for hidden treasure. -- Henry Kissinger -- This quote is generated by: /usr/pkg/bin/curl -L http://tinyurl.com/veusy \ | sed -e 's/^document\.write(.//' -e 's/.);$/ --/' \ -e 's/<[^>]*>//g' -e 's/^More quotes from //' \ | fmt | tee ~/.signature-quote