Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-03-08 23:36:54

Joel de Guzman <joel_at_[hidden]> writes:

> David Abrahams wrote:
>> "Peter Dimov" <pdimov_at_[hidden]> writes:
>>>Gennadiy Rozental wrote:
>>>>I believe this version is much less intuitive. optional<T> v is still
>>>>value of type T which may or may not be present. Accordingly when we
>>>>print it we print the value if it present or print nothing if it not.
>>> This isn't very useful. The output cannot be read back, and when
>>> printing a sequence of optionals much of the information is lost.
>> Agreed. I was going to say that an empty optional should print
>> something, but couldn't articulate the reasons. Thanks.
> Perhaps do as the tuples do?
> [123] <- a non-empty optional<int>
> [] <- an empty optional<T>

If you want to be unambiguous, it has to be more like:

     [hello] <- a non-empty optional<std::string>
     [] <- a non-empty optional<std::string> (the string is empty)
     _ <- an empty optional<T>


Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at