
David Abrahams wrote:
"Peter Dimov" <pdimov@mmltd.net> writes:
I should have been more clear. You shouldn't attempt to fix the output of a std::string in optional<>'s operator<<. The proper way to make a std::string bi-directional is by defining appropriate operator<< and operator>> overloads for std::string. As these operators are already defined and are not bi-directional in the general case, optional<std::string> should not attempt to provide extra bi-directionality.
Okay, I don't neccessarily disagree, but I don't agree yet either. Why?
When a type's operator<< is "broken", you can't fix it from the outside. struct X { std::string data; }; ostream& operator<< ( ostream& os, X const & x ) { return os << x.data; } It is not reasonable to expect all types that rely on string::<< to fix it to match your (arbitrary, I might add) convention.