Subject: Re: [boost] Heads up - string_ref landing
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2012-11-27 01:54:48
On Tue, Nov 27, 2012 at 10:44 AM, Yanchenko Maxim
> 27.11.12, 14:24, "Andrey Semashev" <andrey.semashev_at_[hidden]>":
>> +1, string_ref by definition doesn't own the referred characters. Its
>> presence is enough indication that the storage of the characters has
>> to be managed elsewhere.
> Unfortunately there is absolutely no indication of its presence if you make the construction implicit. Implicitly constructible types are invisible at the point of use, this is the problem.
> This is exactly what I'm talking about: there should be clear indication of what's going on, and it should be at the point of use, not in function declaration or in docs.
> Making it implicit is a way to error-prone user code.
>> And from the user's perspective it should be as transparent as possible.
> What about making implicit conversion from auto_ptr<T*> to T*? Enforcing use of get() is not transparent as possible either.
> What about getting rid of c_str()?
> Isn't safety the reason of having both?
When passing arguments to functions, c_str() and get() are exactly the
things we want to get rid of. That's where string_ref helps. If you
want to store string_ref in a container then either bear in mind that
the string_refs do not own the storage or choose a different type for
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk