|
Boost : |
Subject: Re: [boost] Heads up - string_ref landing
From: Yakov Galka (ybungalobill_at_[hidden])
Date: 2012-12-13 12:18:40
On Thu, Dec 13, 2012 at 7:05 PM, Gottlob Frege <gottlobfrege_at_[hidden]>wrote:
> On Thu, Dec 13, 2012 at 5:20 AM, Rob Stewart <robertstewart_at_[hidden]
> >wrote:
>
> > >>
> > >> It is the logical interpretation. It indicates whether the string is
> > >> non-empty. I don't see any other generally useful interpretation, do
> > you?
> > >
> > > Qt's QString has both empty() and isNull() and they are not always the
> > same. Basically empty() is a zero-byte string, but null is a
> > > never-been-set-or-allocated string.
> > [snip]
> >
> > > Somewhat like optional<string>.
> >
> > That's how I'd spell it.
> [...] For string_ref, it could mean the difference between these 2
> string_refs,
> assuming a ptr+size implementation:
>
> { ptr != 0, size == 0 } and { ptr == 0, size == hopefully_zero }
>
Right. And I want to note that it does matter. At least for std::string,
whose constructor
basic_string(const charT* s, size_type n, const Allocator& a =
Allocator());
explicitly requires that `s` is be a non-null pointer (even if n == 0).
-- Yakov
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk