Subject: Re: [boost] [string_ref] degree of conformance to standard proposal
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2013-12-22 20:26:01
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; Ive 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
> (http://gcc.gnu.org/ml/libstdc++/2013-11/msg00104.html). But for Boost
> I don't see how this can be changed without introducing a link
Not to mention that if you initialize a string_ref ( NULL, 0 )
then requiring its data() call to return non-null means extra code.
If the length of the string_ref is 0, then the return value of data() is meaningless; you cant do anything useful with it.
* You cant dereference it, any more than you can dereference the end() iterator of a vector.
* You cant compare it to a pointer in another container (undefined behavior).
* You can compare it with NULL, but what does that tell you?
> In a cases like this, how closely does Boost want to track the standard
> Similarly, the standard proposal has settled on *string_view instead of
> *string_ref. Would Boost rename the library/class, or just introduce an
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.
[ Im 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 ]
Marshall Clow Idio Software <mailto:mclow.lists_at_[hidden]>
A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
-- Yu Suzuki
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk