C++ Logo

std-proposals

Advanced search

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

From: Dominic Fandrey <isocpp.id_at_[hidden]>
Date: Mon, 10 Aug 2020 15:40:28 +0200
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 &);

I would even hope for this one:

constexpr std::string operator +(std::string_view const &, std::string_view const &);

I agree that implicit conversion from a view back to std::string invokes the danger
of accidentally enabling an expensive std::string construction, but in this case
I think it is clear that the operator must create a std::string instance.

Received on 2020-08-10 08:43:53