Boost logo

Boost :

Subject: Re: [boost] Heads up - string_ref landing
From: Olaf van der Spek (ml_at_[hidden])
Date: 2012-12-13 12:36:59


On Thu, Dec 13, 2012 at 6:18 PM, Yakov Galka <ybungalobill_at_[hidden]> wrote:
>> [...] 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

True. In general containers / ranges have an empty state but not a
null state and operator bool() should return !empty() IMO.

> 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).

Sounds like a bug / defect.

-- 
Olaf

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