Add op+(StringRef, StringRef) -> std::string

This commit is contained in:
Martin Hořeňovský
2020-05-31 22:30:41 +02:00
parent f2b9508081
commit 317145514f
10 changed files with 89 additions and 7 deletions

View File

@@ -39,6 +39,14 @@ namespace Catch {
return os.write(str.data(), str.size());
}
std::string operator+(StringRef lhs, StringRef rhs) {
std::string ret;
ret.reserve(lhs.size() + rhs.size());
ret += lhs;
ret += rhs;
return ret;
}
auto operator+=( std::string& lhs, StringRef const& rhs ) -> std::string& {
lhs.append(rhs.data(), rhs.size());
return lhs;

View File

@@ -101,6 +101,7 @@ namespace Catch {
friend std::string& operator += (std::string& lhs, StringRef const& sr);
friend std::ostream& operator << (std::ostream& os, StringRef const& sr);
friend std::string operator+(StringRef lhs, StringRef rhs);
};