Boost logo

Boost :

Subject: Re: [boost] [string_ref] degree of conformance to standard proposal
From: Peter A. Bigot (pab_at_[hidden])
Date: 2013-12-24 15:30:33

On 12/22/2013 07:26 PM, Marshall Clow wrote:
> On Dec 22, 2013, at 6:21 AM, Peter A. Bigot <pab_at_[hidden]> wrote:
>> (Background: I need a string_view with features in N3762 that aren't in
>> N3442 (viz., pos parameters to the string methods). I'm trying to
>> determine how much effort I should put into a set of patches to update
>> the Boost implementation to the latest draft proposal.)
>> The default constructor for Boost.string_ref produces an object which
>> returns a null pointer from data(). N3442 and its successor N3762 both
>> require the return value from data() to be non-null
>> (
> Yeah; I’ve spoken to Jeffrey (author of the proposal) and will be filing a defect report about that.
>> GCC's libstdc++ folks solved this by adding a constexpr unit length
>> string to serve as the base referenced object
>> ( But for Boost
>> I don't see how this can be changed without introducing a link
>> dependency.
> Right.
> Not to mention that if you initialize a string_ref ( NULL, 0 )

To correct my previous comment, that constructor specifically disallows
passing NULL; I believe the string_ref(char*) one disallows it
implicitly. As I read N3762 there is no way to have a string_view
reference something that isn't a valid (possibly zero-length) character

>> Similarly, the standard proposal has settled on *string_view instead of
>> *string_ref. Would Boost rename the library/class, or just introduce an
>> alias?
> I have that on my to-do list.
> My thought is to rename the classes to match the standard, but keep the string_ref typedefs for compatibility.
> [ I’m open to other suggestions. ]
> I will happily consider patches for the missing features.
> [ Though my opinion is that replicating the entire interface of std::string in string_[ref|view] is a mistake ]
> has the patches I've
prepared, which are sufficient to meet my needs. At this time I don't
propose to provide patches to fix the potential for null references and
rename the class as both are messier than I want to tackle at this stage
of my Boost experience.


Boost list run by bdawes at, gregod at, cpdaniel at, john at