Subject: Re: [boost] Heads up - string_ref landing
From: Yanchenko Maxim (maximyanchenko_at_[hidden])
Date: 2012-11-16 04:28:22
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().
OTOH, storing only pointers is conceptually cleaner.
> >> 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?
Not from std::string. Same argument as for not having implicit conversion to char*.
> 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?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk