diff options
| author | Phil Nash | 2017-11-17 18:54:12 +0000 |
|---|---|---|
| committer | Phil Nash | 2017-11-20 16:33:05 +0000 |
| commit | 4353614df70350ca4eb67caa1c920e221891b212 (patch) | |
| tree | c610da55b287573577e3604e067baa0362cc21f0 /include/internal/catch_stringref.cpp | |
| parent | f36817ef830a85e3b86c2d2158f65845ed1117c6 (diff) | |
| download | catch3-4353614df70350ca4eb67caa1c920e221891b212.tar.gz | |
Added StringRef constructor that captures string literal size at compile time
Diffstat (limited to 'include/internal/catch_stringref.cpp')
| -rw-r--r-- | include/internal/catch_stringref.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/internal/catch_stringref.cpp b/include/internal/catch_stringref.cpp index 49d9629f..41c6ac5c 100644 --- a/include/internal/catch_stringref.cpp +++ b/include/internal/catch_stringref.cpp @@ -16,6 +16,11 @@ #include <ostream> namespace Catch { + auto StringRef::fromRaw( char const* rawChars ) -> StringRef { + return rawChars + ? StringRef( rawChars,static_cast<StringRef::size_type>(std::strlen(rawChars) ) ) + : StringRef(); + } StringRef::operator std::string() const { return std::string( m_start, m_size ); |