|
Boost : |
Subject: Re: [boost] Heads up - string_ref landing
From: Olaf van der Spek (ml_at_[hidden])
Date: 2012-11-24 08:17:47
On Sat, Nov 24, 2012 at 8:42 AM, Yakov Galka <ybungalobill_at_[hidden]> wrote:
>> fundamental? hardly. std::string is not guaranteed to
>> be null terminated.
>
>
> Guaranteed (almost) since C++11. c_str() and data() now *mean the same
> thing*,
Really? Got a reference for that?
> and s[s.size()] returned null even in C++03.
Is that defined behaviour?
You're essentially dereferencing end().
> The only thing that is
> not guaranteed is that *(&s[0] + s.size()) is null. Anyway the point is
> that you can retrieve a null terminated string from std::string in constant
> time, without copying anything. So it is practically null terminated.
True, but that's std::string. Not all strings are std::string.
" A string_ref that's not required to be null-terminated is far more
useful." still holds.
-- Olaf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk