mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 05:45:39 +02:00
Add op+(StringRef, StringRef) -> std::string
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user