Add operator for concatenating strings and string_views

This commit is contained in:
Eelco Dolstra
2022-06-02 21:26:21 +02:00
parent 24b3a500a7
commit abb80cfa4c
+15
View File
@@ -700,4 +700,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;
}
}