|
Boost : |
Subject: Re: [boost] Heads up - string_ref landing
From: Olaf van der Spek (ml_at_[hidden])
Date: 2012-11-15 16:01:17
On Thu, Nov 15, 2012 at 9:32 PM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> Why? I don't see that it makes any
> difference whatsoever.
It's just an implementation detail, indeed.
>>> The header will be in boost/algorithm/string_ref.hpp, but I welcome discussion about where it should live.
>>> Ideally, I think it should be just "boost/string_ref.hpp".
>>
>> I'd go with the latter.
>> I'm missing explicit operator bool() const { return !empty(); }
>>
>
> -1. A string is not a boolean value
Neither is an iostream. Or an int or a pointer. What's your point?
> nor is an empty string a special invalid
> value. If you want to know whether a string
> is empty, you should call s.empty().
That's a bit hard when you've got code like while (string_ref s = f())
or if (string_ref s = f())
Empty/non-empty is a clear and frequently tested distinction and one
of the two happens to be the default value.
-- Olaf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk