C++ Logo

std-proposals

Advanced search

Re: missing operator + and += overloads for std::string_view

From: Dominic Fandrey <isocpp.id_at_[hidden]>
Date: Tue, 11 Aug 2020 08:50:44 +0200
On 10/08/2020 17:09, Barry Revzin wrote:
> On Mon, Aug 10, 2020 at 8:40 AM Dominic Fandrey via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> I think it is probably an oversight and not intentional that those are not
>> there:
>>
>> constexpr std::string operator +(std::string const &, std::string_view
>> const &);
>> constexpr std::string operator +(std::string_view const &, std::string
>> const &);
>> constexpr std::string operator +=(std::string &, std::string_view const &);
>>
>
> It was intentional. From N3512 (
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3512.html):
>
>> I also omitted operator+(basic_string, basic_string_ref) because LLVM
> returns a lightweight object from this overload and only performs the
> concatenation lazily. If we define this overload, we'll have a hard time
> introducing that lightweight concatenation later.

Doesn't that end up with all kinds of templates being matched to the wrong
type all over the place? Well, as long as there's a reason for that I can
live with it.

> string_ref was then renamed to string_view.

Received on 2020-08-11 01:54:08