diff options
| author | Martin Hořeňovský | 2020-05-31 22:30:41 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-05-31 22:30:41 +0200 |
| commit | 317145514fad8266edbce1145391524b4e948f32 (patch) | |
| tree | ded467f5bb8fd770094c7a48ad7ade2f162f893a /src/catch2 | |
| parent | f2b95080815c873a64b76b8052472aa7a4fd6e9f (diff) | |
| download | catch3-317145514fad8266edbce1145391524b4e948f32.tar.gz | |
Add op+(StringRef, StringRef) -> std::string
Diffstat (limited to 'src/catch2')
| -rw-r--r-- | src/catch2/internal/catch_stringref.cpp | 8 | ||||
| -rw-r--r-- | src/catch2/internal/catch_stringref.hpp | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/catch2/internal/catch_stringref.cpp b/src/catch2/internal/catch_stringref.cpp index 4b0bbae6..df375eba 100644 --- a/src/catch2/internal/catch_stringref.cpp +++ b/src/catch2/internal/catch_stringref.cpp @@ -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; diff --git a/src/catch2/internal/catch_stringref.hpp b/src/catch2/internal/catch_stringref.hpp index 1e07b6ad..773d6d33 100644 --- a/src/catch2/internal/catch_stringref.hpp +++ b/src/catch2/internal/catch_stringref.hpp @@ -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); }; |