Boost logo

Boost :

Subject: Re: [boost] Heads up - string_ref landing
From: Olaf van der Spek (ml_at_[hidden])
Date: 2012-11-16 04:33:24

On Fri, Nov 16, 2012 at 10:28 AM, Yanchenko Maxim
<maximyanchenko_at_[hidden]> wrote:
> 16.11.12, 12:30, "Olaf van der Spek":
>> >> 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.
> Yes, it's cheap to calculate (end ptr is equally cheap to calculate btw) but you'll end up calculating it all the time in almost every function. At least my analysis showed that in real app size() is called much more frequently than end().

Really? Do you use subscripted access then? With iterator access you'd
use end().

> OTOH, storing only pointers is conceptually cleaner.

You can derive size in bytes and memory range from a ptr pair without
type info. That may be handy when debugging and in other situations.
You can't do that with (ptr, size) without type info.

>> Shouldn't they be implicit?
> Not from std::string. Same argument as for not having implicit conversion to char*.

What argument would that be?

>> There's also mutable_str_ref for non-const char and data_ref for and
>> mutable_data_ref for unsigned char.
> These are typedefs I assume?

Yes, there are.


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