|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-03-09 11:03:59
David Abrahams wrote:
> "Peter Dimov" <pdimov_at_[hidden]> writes:
>
>> David Abrahams wrote:
>>> 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>
>>
>> My preference is
>>
>> hello
>>
>> _
>>
>> A string can never be output "correctly", no matter what the
>> delimiters are ("a] [b").
>
> I disagree. You can generate escapes:
>
> [a\] \[b]
>
> or if you like,
>
> [a\]\ \[b]
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.
I would concentrate on making simple bi-directional types working correctly,
and outputting a placeholder token such as _ for an empty optional is one
way to accomplish this that produces a reasonably clear output (although it
requires a putback, which is sadly not guaranteed to work).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk