Subject: Re: [boost] Heads up - string_ref landing
From: Olaf van der Spek (ml_at_[hidden])
Date: 2012-11-16 03:28:05
On Fri, Nov 16, 2012 at 6:30 AM, Jeffrey Lee Hellrung, Jr.
> How is this different from (say) contiguous_range< char > /
> contiguous_range< char const > ? I can imagine a contiguous_range<T> that
> wraps a pair of T*s, which would seem to be a simple generalization of your
> proposed string_ref.
Does contiguous_range exist?
On Fri, Nov 16, 2012 at 7:27 AM, Antony Polukhin <antoshkka_at_[hidden]> wrote:
>> 1. This class is essentially just an iterator_ range<char*> (modulo template for
>> const/wchar_t), so it should either inherit from it or have corresponding converting
>> ctors/operators. In this sense Olaf/Gennadiy's remarks are pretty valid. OTOH size
>> is needed very frequently and having it precomputed is a good thing, so conversion
Size is cheap to calculate, it's not worth storing it.
Standardizing the layout of this type might be good too for ABI
stability and maybe interoperability.
>> approach seems to be better (but then we lose passing by reference as
>> iterator_range, type_traits etc).
>> I'm not sure what's more important.
> +1 for having corresponding explicit converting ctors/operators.
Shouldn't they be implicit?
string s = "Olaf";
You don't want to have to wrap all those arguments in an explicit constructor.
>> 2. Given the above, the name is misleading as it's not a reference to std::string.
>> We use name char_range.
> Better then other names, but at first glance it is not clear, that
> char_range can be used as string.
I went for str_ref. It's a bit shorter and the link to string is a bit weaker.
There's also mutable_str_ref for non-const char and data_ref for and
mutable_data_ref for unsigned char.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk