mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 14:56:15 +02:00
Add operator for concatenating strings and string_views
This commit is contained in:
parent
0d3392bef1
commit
53869fbd42
1 changed files with 15 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue