Boost logo

Boost :

Subject: Re: [boost] Heads up - string_ref landing
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2012-11-17 17:34:02


On November 18, 2012 1:29:06 AM Mathias Gaunard
<mathias.gaunard_at_[hidden]> wrote:
> On 16/11/12 15:50, Maxim Yanchenko wrote:
> > Mathias Gaunard <mathias.gaunard <at> ens-lyon.org> writes:
> >
> >>> If this is all you need, just use plain references.
> >>
> >> void f(std::string const&);
> >> f("Olaf");
> >>
> >> does make a useless copy.
> >
> > OK. I thought you were talking about Olaf's desire to have implicit
> conversion
> > from std::string.
> > For this we use just
> > f(char_range::literal("Olaf"));
>
> basic_string_ref<T> is meant to when being implicitly constructed from a
> T(&)[N] or T const* that it is null-terminated.
>
> I don't even understand why people are still discussing this and making
> ridiculous proposals.
> If you want the above use boost::iterator_range<char*>.
>

There is no way to safely detect a string literal, so unless you want
to strlen it anyway the construction has to be explicit.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk