Subject: Re: [boost] [optional_io] InputStreamable refinement
From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2009-03-03 09:55:45
Fernando Cacciola <fernando.cacciola <at> gmail.com> writes:
> Or are you saying that, since supporting such a requirement is not
> entirely possible since in the end is up to T, it isn't worth doing the
> best optional<T> itself can?
Yes, that's what I'm saying except that I tend to disagree with the word
"best" in this part of your sentence "doing the best optional<T> itself can" :)
I believe, based on my reading of documentation, that my proposal is more
> > I don't care about lexical_cast here
> OK, but you two clearly care for extracting an optional<T> from a stream
> that was insterted a bare T instead of an optional<T>.
You're right. Current version of boost doesn't support this
lexical_cast< optional<int> >(0)
but I'm going to make a special case when TargetType is optional<T>
to return a default value rather than throwing an exception:
lexical_cast< optional<int> >("not a number").get_value_or(0);
Since it's a special case, I can easily avoid using optional_io.hpp.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk