Add operator for concatenating strings and string_views

This commit is contained in:
Eelco Dolstra 2022-05-09 14:28:27 +02:00
parent 0d3392bef1
commit 53869fbd42

View file

@ -706,4 +706,19 @@ template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
std::string showBytes(uint64_t bytes);
/* Provide an addition operator between strings and string_views
inexplicably omitted from the standard library. */
inline std::string operator + (const std::string & s1, std::string_view s2)
{
auto s = s1;
s.append(s2);
return s;
}
inline std::string operator + (std::string && s, std::string_view s2)
{
s.append(s2);
return s;
}
}