Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2012-02-13 11:25:32
> >> Side question: is streamablity going to be in your proposal?
> > It is not currently. The reason for that is that there is no clear way
> > it should be implemented (a similar issue applies to pairs, tuples,
> > variant, any, etc...) See
> > http://lists.boost.org/Archives/boost/2005/03/81619.php
> > believe that the problem is with the streaming itself. For instance,
> > streaming out and then streaming the result back in produce the same
> > Some people expect that, but even std::string could not provide this
> > behavior.
> I'd do only << and forget about >>
But even that appears like a non-obvious thing to me. Would other people
here in the list, and also developers in general agree that it is ok that
you have output operation but no input operation? I think that in the
standard library they always go in pairs. (I am not sure, though).
Also, how would you implement it? 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:
optional<string> o1; // uninitialized
optional<string> o2 = "?";
cout << o1;
cout << o2;
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.
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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk