
On Mon, Feb 13, 2012 at 5:25 PM, Andrzej Krzemienski <akrzemi1@gmail.com> wrote:
Also, how would you implement it?
if (o1) os << *o1;
what should an uninitialized optional print? Nothing? but how is having printed an uninitialized optional<int> different that not having printed anything? A question mark? but how would the following two be different:
They won't.
If you propose to provide only output operation, then it looks like you want this for some sort of logging. But perhaps it is better to have some overloaded function toString() that converts all the types to strings.
Isn't that what << is for? :p
Usually the string format that works for one program does not work for the other. And there appears to be no natural/intuitive way of representing any type (like optional) as text.
Right and that's not limited to optional. Defining no IO seems ok too. -- Olaf