Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_stringref.cpp
diff options
context:
space:
mode:
authorPhil Nash2017-11-17 18:54:12 +0000
committerPhil Nash2017-11-20 16:33:05 +0000
commit4353614df70350ca4eb67caa1c920e221891b212 (patch)
treec610da55b287573577e3604e067baa0362cc21f0 /include/internal/catch_stringref.cpp
parentf36817ef830a85e3b86c2d2158f65845ed1117c6 (diff)
downloadcatch3-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.cpp5
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 );