Boost logo

Boost :

Subject: Re: [boost] Heads up - string_ref landing
From: Yakov Galka (ybungalobill_at_[hidden])
Date: 2012-12-12 08:21:32


On Wed, Dec 12, 2012 at 2:55 PM, Rob Stewart <robertstewart_at_[hidden]>wrote:

> On Dec 12, 2012, at 2:38 AM, Yakov Galka <ybungalobill_at_[hidden]> wrote:
>
> > On Tue, Dec 11, 2012 at 11:47 PM, Rob Stewart <robertstewart_at_[hidden]
> >wrote:
> >
> >> On Dec 10, 2012, at 7:55 AM, Sergey Cheban <s.cheban_at_[hidden]> wrote:
> >>
> >>> On 09.12.2012 17:13, Rob Stewart wrote:
> >>>
> >>>>>> - safe bool or explicit bool conversion operator
> >>>>> I don't think this is a good idea.
> >>>> Why not?
> >>> This seems to be not intuitive and not so safe.
> >>
> >> It is quite intuitive to me. true means non-null, and false means null.
> >>
> >
> > Would it mean !empty() or !!begin()?
>
> The former certainly. string_ref's are never assumed to be null terminated
> (which is why I provide data() and not c_str()), so the latter is not
> sensible.
>

I wrote !!begin(), not !!*begin(). In other works string_ref can *actually
be a null pointer*, or at least I haven't seen anyone saying the contrary.

>> The std::string has no such operator.
> >>
> >> Why does that matter? It's still convenient. It would be a nice
> addition to std::string.
> >>
> >
> > std::string does not have a 'null' state.
>
> It's the state represented by empty().
>

I am not sure it is so certainly accepted by all.

-- 
Yakov

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk